Removed -Werror=unused-result warnings.
Subsystems (2)
PATCH 1/1 Removed -Werror=unused-result warnings.
--- support/nfs/nfs_mntent.c | 3 ++- utils/blkmapd/device-discovery.c | 6 ++++-- utils/mount/network.c | 8 ++++++-- utils/nfsd/nfssvc.c | 5 +++-- utils/statd/statd.c | 3 ++- 5 files changed, 17 insertions(+), 8 deletions(-)
support/nfs/nfs_mntent.c +2 -1
@@ -150,7 +150,8 @@ nfs_addmntent (mntFILE *mfp, struct mntent *mnt) { res =fflush (mfp->mntent_fp);if (res <0 )/* Avoid leaving a corrupt mtab file */ -ftruncate (fileno (mfp->mntent_fp), length); +if (ftruncate (fileno (mfp->mntent_fp), length)) + {/* ignore return value */ }; }return (res <0 ) ?1 :0 ; }
utils/blkmapd/device-discovery.c +4 -2
@@ -504,9 +504,11 @@ int main(int argc, char **argv)close (pidfd);exit (1 ); } -ftruncate (pidfd,0 ); +if (ftruncate (pidfd,0 ) <0 ) +BL_LOG_WARNING ("ftruncate on %s failed: m\n" ,PID_FILE );sprintf (pidbuf,"%d\n" ,getpid ()); -write (pidfd, pidbuf,strlen (pidbuf)); +if (write (pidfd, pidbuf,strlen (pidbuf)) != (ssize_t )strlen (pidbuf)) +BL_LOG_WARNING ("write on %s failed: m\n" ,PID_FILE ); }signal (SIGINT , sig_die);
utils/mount/network.c +6 -2
@@ -811,8 +811,12 @@ int start_statd(void)switch (pid) {case 0 :/* child */ setgroups (0 ,NULL ); -setgid (0 ); -setuid (0 ); +if (setgid (0 ) <0 ) +nfs_error (_ ("%s: setgid(0) failed: %s" ), + progname,strerror (errno)); +if (setuid (0 ) <0 ) +nfs_error (_ ("%s: setuid(0) failed: %s" ), + progname,strerror (errno));execle (START_STATD ,START_STATD ,NULL , envp);exit (1 );case -1 :/* error */
utils/nfsd/nfssvc.c +3 -2
@@ -68,7 +68,7 @@ nfssvc_mount_nfsdfs(char *progname)* mount nfsdfs when nfsd.ko is plugged in. So, ignore the return * code from it and just check for the "threads" file afterward. */ -system ("/bin/mount -t nfsd nfsd " NFSD_FS_DIR " >/dev/null 2>&1" ); + err =system ("/bin/mount -t nfsd nfsd " NFSD_FS_DIR " >/dev/null 2>&1" ); err =stat (NFSD_THREAD_FILE , &statbuf);if (err ==0 )
@@ -325,7 +325,8 @@ nfssvc_set_time(const char *type, const int seconds)/* set same value for lockd */ fd =open ("/proc/sys/fs/nfs/nlm_grace_period" ,O_WRONLY );if (fd >=0 ) { -write (fd, nbuf,strlen (nbuf)); +if (write (fd, nbuf,strlen (nbuf)) != (ssize_t )strlen (nbuf)) +xlog (L_ERROR ,"Unable to write nlm_grace_period : %m" );close (fd); } }
utils/statd/statd.c +2 -1
@@ -225,7 +225,8 @@ static void set_nlm_port(char *type, int port) fd =open (pathbuf,O_WRONLY );if (fd <0 && errno ==ENOENT ) {/* probably module not loaded */ -system ("modprobe lockd" ); +if (system ("modprobe lockd" )) + {/* ignore return value */ }; fd =open (pathbuf,O_WRONLY ); }if (fd >=0 ) {
Signature · 1 line
2.14.3
Hi Steve-
Quoted 16 lines · Steve Dickson
=20
Signed-off-by Steve Dickson <[email protected]>---
support/nfs/nfs_mntent.c | 3 ++- utils/blkmapd/device-discovery.c | 6 ++++-- utils/mount/network.c | 8 ++++++-- utils/nfsd/nfssvc.c | 5 +++-- utils/statd/statd.c | 3 ++- 5 files changed, 17 insertions(+), 8 deletions(-)=20
support/nfs/nfs_mntent.c +0
-0
support/nfs/nfs_mntent.c nfs_addmntent (mntFILE *mfp, struct mntent *mnt) { · line 154
Quoted 6 lines
support/nfs/nfs_mntent.c +2
-1@@ -150,7 +150,8 @@ nfs_addmntent (mntFILE *mfp, struct mntent *mnt) { res =3D fflush(mfp->mntent_fp);if (res <0 )/* Avoid leaving a corrupt mtab file */ -ftruncate (fileno (mfp->mntent_fp), length); +if (ftruncate (fileno (mfp->mntent_fp), length)) + {/* ignore return value */ };
Why not
(void)ftruncate(fileno(mfp->mntent_fp), length);
?
=
Quoted 4 lines
support/nfs/nfs_mntent.c +0
-0}return (res <0 ) ?1 :0 ; }= renamed from utils/blkmapd/device-discovery.c +0
-0
b/utils/blkmapd/device-discovery.c
utils/blkmapd/device-discovery.c int main(int argc, char **argv) · line 508
Quoted 10 lines
index b71c949..1afc80f 100644
utils/blkmapd/device-discovery.c +2
-1@@ -504,9 +504,11 @@ int main(int argc, char **argv)close (pidfd);exit (1 ); } -ftruncate (pidfd,0 ); +if (ftruncate (pidfd,0 ) <0 ) + BL_LOG_WARNING("ftruncate on %s failed: m\n", =
PID_FILE);
utils/blkmapd/device-discovery.c int main(int argc, char **argv)
Quoted 3 lines
utils/blkmapd/device-discovery.c +1
-1sprintf (pidbuf,"%d\n" ,getpid ()); -write (pidfd, pidbuf,strlen (pidbuf)); + if (write(pidfd, pidbuf, strlen(pidbuf)) !=3D =
(ssize_t)strlen(pidbuf))
utils/blkmapd/device-discovery.c int main(int argc, char **argv) · line 511
Quoted 1 line
utils/blkmapd/device-discovery.c +1
-0+ BL_LOG_WARNING("write on %s failed: m\n", =
PID_FILE);
Quoted 8 lines
utils/blkmapd/device-discovery.c +0
-0}=20
signal(SIGINT, sig_die);utils/mount/network.c +0
-0
utils/mount/network.c int start_statd(void) · line 815
Quoted 7 lines
utils/mount/network.c +2
-2@@ -811,8 +811,12 @@ int start_statd(void)switch (pid) {case 0 :/* child */ setgroups (0 ,NULL ); -setgid (0 ); -setuid (0 ); +if (setgid (0 ) <0 ) + nfs_error(_("%s: setgid(0) =
failed: %s"),
utils/mount/network.c int start_statd(void) · line 816
Quoted 1 line
utils/mount/network.c +1
-0+ progname, =
strerror(errno));
utils/mount/network.c int start_statd(void) · line 818
Quoted 2 lines
utils/mount/network.c +2
-0+if (setuid (0 ) <0 ) + nfs_error(_("%s: setuid(0) =
failed: %s"),
utils/mount/network.c int start_statd(void) · line 819
Quoted 1 line
utils/mount/network.c +1
-0+ progname, =
strerror(errno));
utils/mount/network.c int start_statd(void) · line 820
Quoted 1 line
utils/mount/network.c +0
-0execle(START_STATD, START_STATD, NULL, =
envp);
utils/nfsd/nfssvc.c nfssvc_mount_nfsdfs(char *progname) · line 68
Quoted 8 lines
utils/mount/network.c +0
-0exit (1 );case -1 :/* error */ utils/nfsd/nfssvc.c +0
-0@@ -68,7 +68,7 @@ nfssvc_mount_nfsdfs(char *progname)* mount nfsdfs when nfsd.ko is plugged in. So, ignore the =
return
utils/nfsd/nfssvc.c nfssvc_mount_nfsdfs(char *progname)
Quoted 3 lines
utils/nfsd/nfssvc.c +0
-1* code from it and just check for the "threads" file afterward. */ - system("/bin/mount -t nfsd nfsd " NFSD_FS_DIR " >/dev/null =
2>&1");
utils/nfsd/nfssvc.c nfssvc_set_time(const char *type, const int =
Quoted 6 lines
utils/nfsd/nfssvc.c +1
-0+ err =3D system("/bin/mount -t nfsd nfsd " NFSD_FS_DIR " = /dev/null 2>&1");=20
err =3D stat(NFSD_THREAD_FILE, &statbuf); if (err =3D=3D 0)utils/nfsd/nfssvc.c +0
-0@@ -325,7 +325,8 @@ nfssvc_set_time(const char *type, const int =
seconds)
utils/nfsd/nfssvc.c nfssvc_set_time(const char *type, const int = · line 326
Quoted 2 lines
utils/nfsd/nfssvc.c +0
-0/* set same value for lockd */ fd =3D open("/proc/sys/fs/nfs/nlm_grace_period", =
O_WRONLY);
utils/nfsd/nfssvc.c nfssvc_set_time(const char *type, const int = · line 328
Quoted 3 lines
utils/nfsd/nfssvc.c +1
-1if (fd >=3D 0) { -write (fd, nbuf,strlen (nbuf)); + if (write(fd, nbuf, strlen(nbuf)) !=3D =
(ssize_t)strlen(nbuf))
utils/nfsd/nfssvc.c nfssvc_set_time(const char *type, const int = · line 329
Quoted 1 line
utils/nfsd/nfssvc.c +1
-0+ xlog(L_ERROR, "Unable to write =
nlm_grace_period : %m");
Quoted 18 lines
utils/nfsd/nfssvc.c +0
-0close (fd); } }utils/statd/statd.c +2
-2@@ -225,7 +225,8 @@ static void set_nlm_port(char *type, int port) fd =3D open(pathbuf, O_WRONLY); if (fd < 0 && errno =3D=3D ENOENT) {/* probably module not loaded */ -system ("modprobe lockd" ); +if (system ("modprobe lockd" )) + {/* ignore return value */ }; fd =3D open(pathbuf, O_WRONLY); } if (fd >=3D 0) { --=20
Quoted 4 lines
2.14.3
=20
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" =
in
Quoted 2 lines
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Chuck Lever
Quoted 27 lines · Chuck Lever
Hi Steve-
Quoted 16 lines · Steve Dickson
Signed-off-by Steve Dickson <[email protected]>---
support/nfs/nfs_mntent.c | 3 ++- utils/blkmapd/device-discovery.c | 6 ++++-- utils/mount/network.c | 8 ++++++-- utils/nfsd/nfssvc.c | 5 +++-- utils/statd/statd.c | 3 ++- 5 files changed, 17 insertions(+), 8 deletions(-)support/nfs/nfs_mntent.c +0
-0support/nfs/nfs_mntent.c nfs_addmntent (mntFILE *mfp, struct mntent *mnt) { · line 154
Quoted 6 lines
support/nfs/nfs_mntent.c +2
-1@@ -150,7 +150,8 @@ nfs_addmntent (mntFILE *mfp, struct mntent *mnt) { res =fflush (mfp->mntent_fp);if (res <0 )/* Avoid leaving a corrupt mtab file */ -ftruncate (fileno (mfp->mntent_fp), length); +if (ftruncate (fileno (mfp->mntent_fp), length)) + {/* ignore return value */ };Why not
Quoted 3 lines
(void)ftruncate(fileno(mfp->mntent_fp), length);?
That was the first I tried and it did not work... I still got the warning/error... If you have any better idea, I'm all hears! :-)
And more strangeness... I did not see these warning/errrors when I compiled the upstream git tree on a Fedora 27 box but I do see them when I take that tree and compile for an Fedora 28 rpm.
Thanks for cycles!
steved.
Quoted 92 lines
Quoted 86 lines
support/nfs/nfs_mntent.c +0
-0}return (res <0 ) ?1 :0 ; }utils/blkmapd/device-discovery.c +4
-2@@ -504,9 +504,11 @@ int main(int argc, char **argv)close (pidfd);exit (1 ); } -ftruncate (pidfd,0 ); +if (ftruncate (pidfd,0 ) <0 ) +BL_LOG_WARNING ("ftruncate on %s failed: m\n" ,PID_FILE );sprintf (pidbuf,"%d\n" ,getpid ()); -write (pidfd, pidbuf,strlen (pidbuf)); +if (write (pidfd, pidbuf,strlen (pidbuf)) != (ssize_t )strlen (pidbuf)) +BL_LOG_WARNING ("write on %s failed: m\n" ,PID_FILE ); }signal (SIGINT , sig_die);utils/mount/network.c +6
-2@@ -811,8 +811,12 @@ int start_statd(void)switch (pid) {case 0 :/* child */ setgroups (0 ,NULL ); -setgid (0 ); -setuid (0 ); +if (setgid (0 ) <0 ) +nfs_error (_ ("%s: setgid(0) failed: %s" ), + progname,strerror (errno)); +if (setuid (0 ) <0 ) +nfs_error (_ ("%s: setuid(0) failed: %s" ), + progname,strerror (errno));execle (START_STATD ,START_STATD ,NULL , envp);exit (1 );case -1 :/* error */ utils/nfsd/nfssvc.c +3
-2@@ -68,7 +68,7 @@ nfssvc_mount_nfsdfs(char *progname)* mount nfsdfs when nfsd.ko is plugged in. So, ignore the return * code from it and just check for the "threads" file afterward. */ -system ("/bin/mount -t nfsd nfsd " NFSD_FS_DIR " >/dev/null 2>&1" ); + err =system ("/bin/mount -t nfsd nfsd " NFSD_FS_DIR " >/dev/null 2>&1" ); err =stat (NFSD_THREAD_FILE , &statbuf);if (err ==0 )@@ -325,7 +325,8 @@ nfssvc_set_time(const char *type, const int seconds)/* set same value for lockd */ fd =open ("/proc/sys/fs/nfs/nlm_grace_period" ,O_WRONLY );if (fd >=0 ) { -write (fd, nbuf,strlen (nbuf)); +if (write (fd, nbuf,strlen (nbuf)) != (ssize_t )strlen (nbuf)) +xlog (L_ERROR ,"Unable to write nlm_grace_period : %m" );close (fd); } }utils/statd/statd.c +2
-1@@ -225,7 +225,8 @@ static void set_nlm_port(char *type, int port) fd =open (pathbuf,O_WRONLY );if (fd <0 && errno ==ENOENT ) {/* probably module not loaded */ -system ("modprobe lockd" ); +if (system ("modprobe lockd" )) + {/* ignore return value */ }; fd =open (pathbuf,O_WRONLY ); }if (fd >=0 ) {Signature · 6 lines
2.14.3 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html--
Chuck Lever
Quoted 14 lines · Steve Dickson
Signed-off-by Steve Dickson <[email protected]>--- support/nfs/nfs_mntent.c | 3 ++- utils/blkmapd/device-discovery.c | 6 ++++-- utils/mount/network.c | 8 ++++++-- utils/nfsd/nfssvc.c | 5 +++-- utils/statd/statd.c | 3 ++- 5 files changed, 17 insertions(+), 8 deletions(-)support/nfs/nfs_mntent.c +0
-0
support/nfs/nfs_mntent.c nfs_addmntent (mntFILE *mfp, struct mntent *mnt) { · line 154
Quoted 6 lines
support/nfs/nfs_mntent.c +2
-1@@ -150,7 +150,8 @@ nfs_addmntent (mntFILE *mfp, struct mntent *mnt) { res =fflush (mfp->mntent_fp);if (res <0 )/* Avoid leaving a corrupt mtab file */ -ftruncate (fileno (mfp->mntent_fp), length); +if (ftruncate (fileno (mfp->mntent_fp), length)) + {/* ignore return value */ };
Might be worth a log warning?
--b.
Quoted 84 lines
support/nfs/nfs_mntent.c +0
-0}return (res <0 ) ?1 :0 ; }utils/blkmapd/device-discovery.c +4
-2@@ -504,9 +504,11 @@ int main(int argc, char **argv)close (pidfd);exit (1 ); } -ftruncate (pidfd,0 ); +if (ftruncate (pidfd,0 ) <0 ) +BL_LOG_WARNING ("ftruncate on %s failed: m\n" ,PID_FILE );sprintf (pidbuf,"%d\n" ,getpid ()); -write (pidfd, pidbuf,strlen (pidbuf)); +if (write (pidfd, pidbuf,strlen (pidbuf)) != (ssize_t )strlen (pidbuf)) +BL_LOG_WARNING ("write on %s failed: m\n" ,PID_FILE ); }signal (SIGINT , sig_die);utils/mount/network.c +6
-2@@ -811,8 +811,12 @@ int start_statd(void)switch (pid) {case 0 :/* child */ setgroups (0 ,NULL ); -setgid (0 ); -setuid (0 ); +if (setgid (0 ) <0 ) +nfs_error (_ ("%s: setgid(0) failed: %s" ), + progname,strerror (errno)); +if (setuid (0 ) <0 ) +nfs_error (_ ("%s: setuid(0) failed: %s" ), + progname,strerror (errno));execle (START_STATD ,START_STATD ,NULL , envp);exit (1 );case -1 :/* error */ utils/nfsd/nfssvc.c +3
-2@@ -68,7 +68,7 @@ nfssvc_mount_nfsdfs(char *progname)* mount nfsdfs when nfsd.ko is plugged in. So, ignore the return * code from it and just check for the "threads" file afterward. */ -system ("/bin/mount -t nfsd nfsd " NFSD_FS_DIR " >/dev/null 2>&1" ); + err =system ("/bin/mount -t nfsd nfsd " NFSD_FS_DIR " >/dev/null 2>&1" ); err =stat (NFSD_THREAD_FILE , &statbuf);if (err ==0 )@@ -325,7 +325,8 @@ nfssvc_set_time(const char *type, const int seconds)/* set same value for lockd */ fd =open ("/proc/sys/fs/nfs/nlm_grace_period" ,O_WRONLY );if (fd >=0 ) { -write (fd, nbuf,strlen (nbuf)); +if (write (fd, nbuf,strlen (nbuf)) != (ssize_t )strlen (nbuf)) +xlog (L_ERROR ,"Unable to write nlm_grace_period : %m" );close (fd); } }utils/statd/statd.c +2
-1@@ -225,7 +225,8 @@ static void set_nlm_port(char *type, int port) fd =open (pathbuf,O_WRONLY );if (fd <0 && errno ==ENOENT ) {/* probably module not loaded */ -system ("modprobe lockd" ); +if (system ("modprobe lockd" )) + {/* ignore return value */ }; fd =open (pathbuf,O_WRONLY ); }if (fd >=0 ) {Signature · 6 lines
2.14.3 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 10 lines · J. Bruce Fields
Quoted 9 lines · Steve Dickson
Signed-off-by Steve Dickson <[email protected]>--- support/nfs/nfs_mntent.c | 3 ++- utils/blkmapd/device-discovery.c | 6 ++++-- utils/mount/network.c | 8 ++++++-- utils/nfsd/nfssvc.c | 5 +++-- utils/statd/statd.c | 3 ++- 5 files changed, 17 insertions(+), 8 deletions(-)
Quoted 13 lines
support/nfs/nfs_mntent.c nfs_addmntent (mntFILE *mfp, struct mntent *mnt) { · line 154
Quoted 11 lines
support/nfs/nfs_mntent.c +2
-1@@ -150,7 +150,8 @@ nfs_addmntent (mntFILE *mfp, struct mntent *mnt) { res =fflush (mfp->mntent_fp);if (res <0 )/* Avoid leaving a corrupt mtab file */ -ftruncate (fileno (mfp->mntent_fp), length); +if (ftruncate (fileno (mfp->mntent_fp), length)) + {/* ignore return value */ };Might be worth a log warning?
Yes... I thought about that. But I could not think of any meaningful log that would help diagnose the problem... The ftruncate() is basically cleanly up a mess..
Maybe log an error message from the fflush()?
Thanks for the review!
steved.
Quoted 26 lines · Steve Dickson
Quoted 10 lines · J. Bruce Fields
Quoted 9 lines · Steve Dickson
Signed-off-by Steve Dickson <[email protected]>--- support/nfs/nfs_mntent.c | 3 ++- utils/blkmapd/device-discovery.c | 6 ++++-- utils/mount/network.c | 8 ++++++-- utils/nfsd/nfssvc.c | 5 +++-- utils/statd/statd.c | 3 ++- 5 files changed, 17 insertions(+), 8 deletions(-)Quoted 13 lines
support/nfs/nfs_mntent.c nfs_addmntent (mntFILE *mfp, struct mntent *mnt) { · line 154
Quoted 11 lines
support/nfs/nfs_mntent.c +2
-1@@ -150,7 +150,8 @@ nfs_addmntent (mntFILE *mfp, struct mntent *mnt) { res =fflush (mfp->mntent_fp);if (res <0 )/* Avoid leaving a corrupt mtab file */ -ftruncate (fileno (mfp->mntent_fp), length); +if (ftruncate (fileno (mfp->mntent_fp), length)) + {/* ignore return value */ };Might be worth a log warning?
Quoted 5 lines
Yes... I thought about that. But I could not think of any meaningful log that would help diagnose the problem... The
ftruncate()is basically cleanly up a mess..Maybe log an error message from the
fflush()?
Yeah, and I admit maybe it's not worth anything specifically by the time the ftruncate also fails.
--b.
Quoted 31 lines · J. Bruce Fields
Quoted 26 lines · Steve Dickson
Quoted 23 lines · J. Bruce Fields
Quoted 14 lines · Steve Dickson
Signed-off-by Steve Dickson <[email protected]>---
support/nfs/nfs_mntent.c | 3 ++- utils/blkmapd/device-discovery.c | 6 ++++-- utils/mount/network.c | 8 ++++++-- utils/nfsd/nfssvc.c | 5 +++-- utils/statd/statd.c | 3 ++- 5 files changed, 17 insertions(+), 8 deletions(-)support/nfs/nfs_mntent.c +0
-0support/nfs/nfs_mntent.c nfs_addmntent (mntFILE *mfp, struct mntent *mnt) { · line 154
Quoted 6 lines
support/nfs/nfs_mntent.c +2
-1@@ -150,7 +150,8 @@ nfs_addmntent (mntFILE *mfp, struct mntent *mnt) { res =fflush (mfp->mntent_fp);if (res <0 )/* Avoid leaving a corrupt mtab file */ -ftruncate (fileno (mfp->mntent_fp), length); +if (ftruncate (fileno (mfp->mntent_fp), length)) + {/* ignore return value */ };Might be worth a log warning?
Quoted 8 lines
Quoted 5 lines
Yes... I thought about that. But I could not think of any meaningful log that would help diagnose the problem... The
ftruncate()is basically cleanly up a mess..Maybe log an error message from the
fflush()?Yeah, and I admit maybe it's not worth anything specifically by the time the ftruncate also fails.
Acknowledging that fact in the comment might be a good idea.
--
Chuck Lever