On Sun, 3 May 2020 at 20:45, Witold Baryluk <witold.bary...@gmail.com> wrote:
>
> Package: manpages-dev
> Version: 5.06-1
> Severity: normal
>
> Reading manual:
>
> """
> int hsearch_r(ENTRY item, ACTION action, ENTRY **retval,
>               struct hsearch_data *htab);
>
> Return Value:
>
> hsearch_r() returns nonzero on success, and 0 on error.
>
> Errors:
>
> hsearch() and hsearch_r() can fail for the following reasons:
> ENOMEM
>
> action was ENTER, key was not found in the table, and there was no room in 
> the table to add a new entry.
>
> ESRCH
>
> action was FIND, and key was not found in the table.
> """
>
>
> Well, there are few issues.
>
> if hsearch_r returns 0 on error, how are the "reasons" indicated back to
> the caller? The manpage doesn't say anything about it.

But, it does, I think (or I have misunderstood your point).. Under
RETURN VALUE, the manual page says:

       On success, hsearch() returns a pointer to an entry  in  the  hash
       table.   hsearch()  returns  NULL  on error, that is, if action is
       ENTER and the hash table is full, or action is FIND and item  can‐
       not  be  found  in the hash table.  hsearch_r() returns nonzero on
       success, and 0 on error.  In the event  of  an  error,  these  two
       functions set errno to indicate the cause of the error.

> Also I would expect the EINVAL to be returned by hsearch_r when htab is
> NULL.

Why would you expect this? you don't explain. I imagine rather that
the error might be EFAUL or Segmentation Violation (SIGSEGV).

Thanks,

Michael

Reply via email to