1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-12 13:18:14 +03:00

user-util: trivial coding style fixes

Use C's downgrade-to-bool feature when comparing pointers against NULL,
as we usually do.
This commit is contained in:
Lennart Poettering 2018-04-19 11:40:48 +02:00
parent 5b3325fedf
commit ad80c6a655

View File

@ -775,11 +775,11 @@ int fgetpwent_sane(FILE *stream, struct passwd **pw) {
errno = 0; errno = 0;
p = fgetpwent(stream); p = fgetpwent(stream);
if (p == NULL && errno != ENOENT) if (!p && errno != ENOENT)
return errno > 0 ? -errno : -EIO; return errno > 0 ? -errno : -EIO;
*pw = p; *pw = p;
return p != NULL; return !!p;
} }
int fgetspent_sane(FILE *stream, struct spwd **sp) { int fgetspent_sane(FILE *stream, struct spwd **sp) {
@ -790,11 +790,11 @@ int fgetspent_sane(FILE *stream, struct spwd **sp) {
errno = 0; errno = 0;
s = fgetspent(stream); s = fgetspent(stream);
if (s == NULL && errno != ENOENT) if (!s && errno != ENOENT)
return errno > 0 ? -errno : -EIO; return errno > 0 ? -errno : -EIO;
*sp = s; *sp = s;
return s != NULL; return !!s;
} }
int fgetgrent_sane(FILE *stream, struct group **gr) { int fgetgrent_sane(FILE *stream, struct group **gr) {
@ -805,11 +805,11 @@ int fgetgrent_sane(FILE *stream, struct group **gr) {
errno = 0; errno = 0;
g = fgetgrent(stream); g = fgetgrent(stream);
if (g == NULL && errno != ENOENT) if (!g && errno != ENOENT)
return errno > 0 ? -errno : -EIO; return errno > 0 ? -errno : -EIO;
*gr = g; *gr = g;
return g != NULL; return !!g;
} }
#if ENABLE_GSHADOW #if ENABLE_GSHADOW
@ -821,10 +821,10 @@ int fgetsgent_sane(FILE *stream, struct sgrp **sg) {
errno = 0; errno = 0;
s = fgetsgent(stream); s = fgetsgent(stream);
if (s == NULL && errno != ENOENT) if (!s && errno != ENOENT)
return errno > 0 ? -errno : -EIO; return errno > 0 ? -errno : -EIO;
*sg = s; *sg = s;
return s != NULL; return !!s;
} }
#endif #endif