[Patch] replace readdir() by g_dir_read_name()



Hi all,

running cppcheck on Balsa/s master sources, I got reports about readdir() not being thread-safe (“portability 
warnings”).  Although there seems to be some confusion about this (see the glibc man page of readdir vs. IEEE 
1003.1-2017), I think the better approach is to use the glib functions which also support other platforms 
like Windows cleanly (NB: the glib implementation uses readdir() for POSIX systems…).

The attached patch replaces readdir() and friends by the glib functions, and also refactors the affected 
functions in libbalsa/folder-scanners.c a little bit as to avoid “continue” statements which (IMHO) make the 
code harder to read.

Opinions?

Cheers,
Albrecht.

---
Patch details:
- libbalsa/folder-scanners.c: replace opendir/readdir/closedir by g_dir_*, and refactor functions 
libbalsa_scanner_mdir() and libbalsa_scanner_local_dir_helper
- libbalsa/mailbox_imap.c: replace opendir/readdir/closedir by g_dir_*

Attachment: replace_readdir_by_g_dir.diff.bz2
Description: application/bzip

Attachment: pgpT6gJviHmYW.pgp
Description: PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]