[pulseaudio-discuss] [PATCH 1/2] Get rid of some warnings: -Wunused-result
Maarten Bosmans
mkbosmans at gmail.com
Sat Mar 19 05:59:15 PDT 2011
modules/module-default-device-restore.c: In function ‘load’:
modules/module-default-device-restore.c:67: warning: ignoring return value of ‘fgets’,
declared with attribute warn_unused_result [-Wunused-result]
modules/module-default-device-restore.c:88: warning: ignoring return value of ‘fgets’,
declared with attribute warn_unused_result [-Wunused-result]
pulsecore/authkey.c: In function ‘generate’:
pulsecore/authkey.c:58: warning: ignoring return value of ‘ftruncate’,
declared with attribute warn_unused_result [-Wunused-result]
pulsecore/core-util.c: In function ‘pa_make_secure_dir’:
pulsecore/core-util.c:261: warning: ignoring return value of ‘fchown’,
declared with attribute warn_unused_result [-Wunused-result]
---
src/modules/module-default-device-restore.c | 8 ++++----
src/pulsecore/authkey.c | 5 ++++-
src/pulsecore/core-util.c | 7 ++++---
3 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/src/modules/module-default-device-restore.c b/src/modules/module-default-device-restore.c
index 94f589e..90f1149 100644
--- a/src/modules/module-default-device-restore.c
+++ b/src/modules/module-default-device-restore.c
@@ -64,8 +64,8 @@ static void load(struct userdata *u) {
char ln[256] = "";
pa_sink *s;
- (void) fgets(ln, sizeof(ln)-1, f);
- pa_strip_nl(ln);
+ if(fgets(ln, sizeof(ln)-1, f))
+ pa_strip_nl(ln);
fclose(f);
if (!ln[0])
@@ -85,8 +85,8 @@ static void load(struct userdata *u) {
char ln[256] = "";
pa_source *s;
- (void) fgets(ln, sizeof(ln)-1, f);
- pa_strip_nl(ln);
+ if (fgets(ln, sizeof(ln)-1, f))
+ pa_strip_nl(ln);
fclose(f);
if (!ln[0])
diff --git a/src/pulsecore/authkey.c b/src/pulsecore/authkey.c
index 92509d8..a590a65 100644
--- a/src/pulsecore/authkey.c
+++ b/src/pulsecore/authkey.c
@@ -55,7 +55,10 @@ static int generate(int fd, void *ret_data, size_t length) {
pa_random(ret_data, length);
lseek(fd, (off_t) 0, SEEK_SET);
- (void) ftruncate(fd, (off_t) 0);
+ if (ftruncate(fd, (off_t) 0) < 0) {
+ pa_log("Failed to truncate cookie file: %s", pa_cstrerror(errno));
+ return -1;
+ }
if ((r = pa_loop_write(fd, ret_data, length, NULL)) < 0 || (size_t) r != length) {
pa_log("Failed to write cookie file: %s", pa_cstrerror(errno));
diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index a713cae..8ff9995 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -254,11 +254,12 @@ int pa_make_secure_dir(const char* dir, mode_t m, uid_t uid, gid_t gid) {
}
#ifdef HAVE_FCHOWN
- if (uid == (uid_t)-1)
+ if (uid == (uid_t) -1)
uid = getuid();
- if (gid == (gid_t)-1)
+ if (gid == (gid_t) -1)
gid = getgid();
- (void) fchown(fd, uid, gid);
+ if (fchown(fd, uid, gid) < 0)
+ goto fail;
#endif
#ifdef HAVE_FCHMOD
--
1.7.1
More information about the pulseaudio-discuss
mailing list