fgets(3) returns either NULL or the input pointer. Checking for NULL is
more explicit, and simpler.
<stddef.h> is the header that provides NULL; add it where appropriate.
The meat of this patch can be approximated with the following semantic
patch:
$ cat ~/tmp/spatch/fgets_null.sp
@@
expression a, b, c;
@@
- fgets(a, b, c) == a
+ fgets(a, b, c) != NULL
@@
expression a, b, c;
@@
- fgetsx(a, b, c) == a
+ fgetsx(a, b, c) != NULL
@@
expression a, b, c, p;
@@
- p->cio_fgets(a, b, c) == a
+ p->cio_fgets(a, b, c) != NULL
@@
expression a, b, c;
@@
- fgets(a, b, c) != a
+ fgets(a, b, c) == NULL
@@
expression a, b, c;
@@
- fgetsx(a, b, c) != a
+ fgetsx(a, b, c) == NULL
@@
expression a, b, c, p;
@@
- p->cio_fgets(a, b, c) != a
+ p->cio_fgets(a, b, c) == NUL
Applied as
$ find contrib/ lib* src/ -type f \
| xargs spatch --sp-file ~/tmp/spatch/fgets_null.sp --in-place;
The differences between the actual patch and the approximation via the
semantic patch from above are includes, whitespace, braces, and a case
where there was an implicit pointer-to-bool comparison which I made
explicit. When reviewing, it'll be useful to use git-diff(1) with '-w'
and '--color-words=.'.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
"config.h" is a locally generated header. It must be included as
'#include "config.h"'.
It is already included correctly in some sources files. This commit
unifies the way how "config.h" is included.
Signed-off-by: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
Except for the added (and sorted) includes, and the removal of redundant
parentheses, this patch can be approximated with the following semantic
patch:
$ cat ~/tmp/spatch/streq.sp;
@@
expression a, b;
@@
- strcmp(a, b) == 0
+ streq(a, b)
@@
expression a, b;
@@
- 0 == strcmp(a, b)
+ streq(a, b)
@@
expression a, b;
@@
- !strcmp(a, b)
+ streq(a, b)
$ find contrib/ lib* src/ -type f \
| xargs spatch --sp-file ~/tmp/spatch/streq.sp --in-place;
$ git restore lib/string/strcmp/streq.h;
Signed-off-by: Alejandro Colomar <alx@kernel.org>
The separation was unnecessary, and caused build problems. Let's go
wild and obliterate the library. The files are moved to libshadow.
Scripted change:
$ find libmisc/ -type f \
| grep '\.[chy]$' \
| xargs mv -t lib;
Plus updating the Makefile and other references. While at it, I've
sorted the sources lists.
Link: <https://github.com/shadow-maint/shadow/pull/792>
Reported-by: David Seifert <soap@gentoo.org>
Cc: Sam James <sam@gentoo.org>
Cc: Christian Bricart <christian@bricart.de>
Cc: Michael Vetter <jubalh@iodoru.org>
Cc: Robert Förster <Dessa@gmake.de>
[ soap tested the Gentoo package ]
Tested-by: David Seifert <soap@gentoo.org>
Acked-by: David Seifert <soap@gentoo.org>
Acked-by: Serge Hallyn <serge@hallyn.com>
Acked-by: Iker Pedrosa <ipedrosa@redhat.com>
Acked-by: <lslebodn@fedoraproject.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>