FLTK logo

Re: [fltk/fltk] scandir_posix.c readentry should check for ENOENT (#238)

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.issues  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: [fltk/fltk] scandir_posix.c readentry should check for ENOENT (#238) michaelbaeuerle Jun 16, 2021  
 

I agree with Albrecht that ENOENT is an error condition (with a different meaning than "end of directory").

This is documented for SUSv2 from the last century:
https://pubs.opengroup.org/onlinepubs/007908799/xsh/readdir.html

| When the end of the directory is encountered, a null pointer is returned and errno is not changed.

and for modern POSIX:
https://pubs.opengroup.org/onlinepubs/9699919799/functions/readdir.html

| When the end of the directory is encountered, a null pointer shall be returned and errno is not changed.

FLTK sets errno to zero and therefore errno must be zero after the readdir() call for "end of directory".

The FLTK function readentry() will return 0 for "end of directory" and -1 for ENOENT.
For the latter case the FLTK function fl_scandir() will abort its loop and return -1 and ENOENT.
This is the intended behaviour in general and I vote against changing it for an unsupported
non-POSIX platform (it is documented that a POSIX conformant readdir() is required).
If readdir() is broken on such a platform, a POSIX conformant readdir() replacement
or a separate implementation for scandir(), e.g. in "scandir_dos.c", should be provided.

If we agree that ENOENT indicates an error:
Directly passing ENOENT through fl_scandir() back to the caller maybe is questionable,
because strictly speaking ENOENT has a different meaning for scandir():
https://pubs.opengroup.org/onlinepubs/9699919799/functions/scandir.html
But it looks like that mapping ENOENT to one of the other error codes would not match better.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.