[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2] Make error handling of public API consistent
From: |
Mohammad-Reza Nabipoor |
Subject: |
Re: [PATCH v2] Make error handling of public API consistent |
Date: |
Wed, 11 Nov 2020 15:34:42 +0330 |
Hi, Jose.
On Wed, Nov 11, 2020 at 12:19:39AM +0100, Jose E. Marchesi wrote:
>
> >> > pk_ios
> >> > pk_ios_cur (pk_compiler pkc)
> >> > {
> >> > + pkc->status = PK_OK;
> >> > return (pk_ios) ios_cur ();
> >> > }
> >>
> >> Can't ios_cur fail?
> >>
> >> > pk_ios
> >> > pk_ios_search (pk_compiler pkc, const char *handler)
> >> > {
> >> > + pkc->status = PK_OK;
> >> > /* XXX use pkc */
> >> > return (pk_ios) ios_search (handler);
> >> > }
> >>
> >> Ditto for ios_search. Can't it fail? What if an IOS having hte given
> >> handler cannot be found?
> >>
> >> > @@ -413,6 +433,7 @@ pk_ios_search (pk_compiler pkc, const char *handler)
> >> > pk_ios
> >> > pk_ios_search_by_id (pk_compiler pkc, int id)
> >> > {
> >> > + pkc->status = PK_OK;
> >> > /* XXX use pkc */
> >> > return (pk_ios) ios_search_by_id (id);
> >> > }
> >>
> >> Likewise.
> >>
> >
> >
> > All `ios_cur`, `ios_search` and `ios_search_by_id` functions will return
> > `NULL`
> > when the entry does not exist.
> > I don't think that's a failure or error. Everything in the library worked
> > as expected and not found the requested item.
>
> Oh, of course.
> We have to return PK_IOS_INVALID in that case, and set status to PK_OK.
>
Do you mean we have to return `NULL`?
Or ...