You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
96 lines
3.1 KiB
96 lines
3.1 KiB
From 0d26e4514d7d6c90d2c5e35749c0b83121a66b77 Mon Sep 17 00:00:00 2001 |
|
From: "mtasaka@fedoraproject.org" <mtasaka@fedoraproject.org> |
|
Date: Tue, 7 Feb 2017 16:40:52 +0900 |
|
Subject: [PATCH] misc: kill gcc warn_unused_result warnings |
|
|
|
Remove misc warnings generated gcc -Wall with |
|
"warning: ignoring return value of 'foo', |
|
declared with attribute warn_unused_result". |
|
|
|
For setuid() and fgets(), really check the returned value. |
|
For system(), for now just use empty body to avoid this |
|
warning. Note that casting the result to (void) does not |
|
remove these warnings. |
|
--- |
|
driver/demo-Gtk.c | 9 +++++++-- |
|
hacks/glx/sonar-icmp.c | 2 +- |
|
hacks/glx/sonar.c | 5 +++-- |
|
hacks/recanim.c | 6 +++++- |
|
4 files changed, 16 insertions(+), 6 deletions(-) |
|
|
|
diff --git a/driver/demo-Gtk.c b/driver/demo-Gtk.c |
|
index f5c4839..7c34846 100644 |
|
--- a/driver/demo-Gtk.c |
|
+++ b/driver/demo-Gtk.c |
|
@@ -4423,7 +4423,8 @@ kde_screensaver_active_p (void) |
|
FILE *p = popen ("dcop kdesktop KScreensaverIface isEnabled 2>/dev/null", |
|
"r"); |
|
char buf[255]; |
|
- fgets (buf, sizeof(buf)-1, p); |
|
+ if (!p) return False; |
|
+ if (!fgets (buf, sizeof(buf)-1, p)) return False; |
|
pclose (p); |
|
if (!strcmp (buf, "true\n")) |
|
return True; |
|
@@ -4434,7 +4435,11 @@ kde_screensaver_active_p (void) |
|
static void |
|
kill_kde_screensaver (void) |
|
{ |
|
- system ("dcop kdesktop KScreensaverIface enable false"); |
|
+ /* Use empty body to kill warning from gcc -Wall with |
|
+ "warning: ignoring return value of 'system', |
|
+ declared with attribute warn_unused_result" |
|
+ */ |
|
+ if (system ("dcop kdesktop KScreensaverIface enable false")) {} |
|
} |
|
|
|
|
|
diff --git a/hacks/glx/sonar-icmp.c b/hacks/glx/sonar-icmp.c |
|
index 8256270..26eb90d 100644 |
|
--- a/hacks/glx/sonar-icmp.c |
|
+++ b/hacks/glx/sonar-icmp.c |
|
@@ -1634,7 +1634,7 @@ sonar_init_ping (Display *dpy, char **error_ret, char **desc_ret, |
|
fprintf (stderr, "%s: unable to open icmp socket\n", progname); |
|
|
|
/* Disavow privs */ |
|
- setuid(getuid()); |
|
+ if (setuid(getuid()) == -1) abort(); |
|
|
|
pd->pid = getpid() & 0xFFFF; |
|
pd->seq = 0; |
|
diff --git a/hacks/glx/sonar.c b/hacks/glx/sonar.c |
|
index f3a4d9d..2c6ca5b 100644 |
|
--- a/hacks/glx/sonar.c |
|
+++ b/hacks/glx/sonar.c |
|
@@ -930,8 +930,9 @@ init_sensor (ModeInfo *mi) |
|
sp->ssd = sonar_init_ping (MI_DISPLAY (mi), &sp->error, &sp->desc, |
|
ping_arg, ping_timeout, resolve_p, times_p, |
|
debug_p); |
|
- else |
|
- setuid(getuid()); /* Disavow privs if not pinging. */ |
|
+ else { |
|
+ if (setuid(getuid()) == -1) abort(); /* Disavow privs if not pinging. */ |
|
+ } |
|
|
|
sp->start_time = double_time (); /* for error message timing */ |
|
|
|
diff --git a/hacks/recanim.c b/hacks/recanim.c |
|
index 51379ed..a526c25 100644 |
|
--- a/hacks/recanim.c |
|
+++ b/hacks/recanim.c |
|
@@ -324,7 +324,11 @@ screenhack_record_anim_free (record_anim_state *st) |
|
" 2>&-", |
|
fn); |
|
fprintf (stderr, "%s: exec: %s\n", progname, cmd); |
|
- system (cmd); |
|
+ /* Use empty body to kill warning from gcc -Wall with |
|
+ "warning: ignoring return value of 'system', |
|
+ declared with attribute warn_unused_result" |
|
+ */ |
|
+ if (system (cmd)) {} |
|
|
|
if (stat (fn, &s)) |
|
{ |
|
-- |
|
2.9.3 |
|
|
|
|