summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKacper Kowalik (Xarthisius) <xarthisius@gentoo.org>2012-11-18 10:49:47 +0100
committerAnthony G. Basile <blueness@gentoo.org>2012-11-18 10:14:19 -0500
commitc189ab04cbaa2f011da0210f2c885e6f693f1d6c (patch)
treee013ea0467292d81b5318106985d3bfeec6a333f /src
parent2af83cafa0f410edc1d60029edfd457e121114a4 (diff)
Fix unused result warnings
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src')
-rw-r--r--src/collect/collect.c9
-rw-r--r--src/libudev/libudev-queue-private.c13
-rw-r--r--src/udev/udev-node.c3
-rw-r--r--src/udev/udev-rules.c3
-rw-r--r--src/udev/udevadm-hwdb.c15
-rw-r--r--src/udev/udevadm-settle.c3
-rw-r--r--src/udev/udevd.c6
7 files changed, 35 insertions, 17 deletions
diff --git a/src/collect/collect.c b/src/collect/collect.c
index 3c46e40de1..3dd702dfab 100644
--- a/src/collect/collect.c
+++ b/src/collect/collect.c
@@ -104,7 +104,8 @@ static int prepare(char *dir, char *filename)
fprintf(stderr, "Lock taken, wait for %d seconds\n", UDEV_ALARM_TIMEOUT);
if (errno == EAGAIN || errno == EACCES) {
alarm(UDEV_ALARM_TIMEOUT);
- lockf(fd, F_LOCK, 0);
+ if (lockf(fd, F_LOCK, 0) == -1)
+ fprintf(stderr, "Failed to acquire lock on %s\n", buf);
if (debug)
fprintf(stderr, "Acquired lock on %s\n", buf);
} else {
@@ -476,10 +477,12 @@ int main(int argc, char **argv)
kickout();
lseek(fd, 0, SEEK_SET);
- ftruncate(fd, 0);
+ if (ftruncate(fd, 0) == -1)
+ fprintf(stderr, "Failed to truncate '%s'\n", checkpoint);
ret = missing(fd);
- lockf(fd, F_ULOCK, 0);
+ if (lockf(fd, F_ULOCK, 0) == -1)
+ fprintf(stderr, "Failed to release lock from '%s'\n", checkpoint);
close(fd);
out:
if (debug)
diff --git a/src/libudev/libudev-queue-private.c b/src/libudev/libudev-queue-private.c
index 80d7ceef2b..51a1d672be 100644
--- a/src/libudev/libudev-queue-private.c
+++ b/src/libudev/libudev-queue-private.c
@@ -224,8 +224,8 @@ static int rebuild_queue_file(struct udev_queue_export *udev_queue_export)
if (new_queue_file == NULL)
goto error;
seqnum = udev_queue_export->seqnum_max;
- fwrite(&seqnum, 1, sizeof(unsigned long long int), new_queue_file);
-
+ if (fwrite(&seqnum, 1, sizeof(unsigned long long int), new_queue_file) != sizeof(unsigned long long int))
+ goto error;
/* copy unfinished events only to the new file */
if (devpaths != NULL) {
for (i = devpaths->devpaths_first; i < devpaths->devpaths_size; i++) {
@@ -239,9 +239,12 @@ static int rebuild_queue_file(struct udev_queue_export *udev_queue_export)
err = udev_queue_read_devpath(udev_queue_export->queue_file, devpath, sizeof(devpath));
devpath_len = err;
- fwrite(&seqnum, sizeof(unsigned long long int), 1, new_queue_file);
- fwrite(&devpath_len, sizeof(unsigned short), 1, new_queue_file);
- fwrite(devpath, 1, devpath_len, new_queue_file);
+ if (fwrite(&seqnum, sizeof(unsigned long long int), 1, new_queue_file) != 1)
+ goto error;
+ if (fwrite(&devpath_len, sizeof(unsigned short), 1, new_queue_file) != 1)
+ goto error;
+ if (fwrite(devpath, 1, devpath_len, new_queue_file) != devpath_len)
+ goto error;
}
seqnum++;
}
diff --git a/src/udev/udev-node.c b/src/udev/udev-node.c
index 7774303704..df3fac8ab6 100644
--- a/src/udev/udev-node.c
+++ b/src/udev/udev-node.c
@@ -282,7 +282,8 @@ static int node_fixup(struct udev_device *dev, mode_t mode, uid_t uid, gid_t gid
if ((stats.st_mode & 0777) != (mode & 0777) || stats.st_uid != uid || stats.st_gid != gid) {
log_debug("set permissions %s, %#o, uid=%u, gid=%u\n", devnode, mode, uid, gid);
chmod(devnode, mode);
- chown(devnode, uid, gid);
+ if (chown(devnode, uid, gid) < 0)
+ log_debug("Failed to change ownership of %s to uid=%u, gid=%u\n", devnode, uid, gid);
} else {
log_debug("preserve permissions %s, %#o, uid=%u, gid=%u\n", devnode, mode, uid, gid);
}
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
index e6f0f5da7e..a85b41185f 100644
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -2552,7 +2552,8 @@ void udev_rules_apply_static_dev_perms(struct udev_rules *rules)
}
if ((uid != 0 && uid != stats.st_uid) || (gid != 0 && gid != stats.st_gid)) {
- chown(filename, uid, gid);
+ if (chown(filename, uid, gid) < 0)
+ log_debug("Following chown failed!");
log_debug("chown '%s' %u %u\n", filename, uid, gid);
}
diff --git a/src/udev/udevadm-hwdb.c b/src/udev/udevadm-hwdb.c
index 02d8d01f8a..e545689f3d 100644
--- a/src/udev/udevadm-hwdb.c
+++ b/src/udev/udevadm-hwdb.c
@@ -313,12 +313,14 @@ static int64_t trie_store_nodes(struct trie_f *trie, struct trie_node *node) {
/* write node */
node_off = ftello(trie->f);
- fwrite(&n, sizeof(struct trie_node_f), 1, trie->f);
+ if (fwrite(&n, sizeof(struct trie_node_f), 1, trie->f) != 1)
+ log_error("Failed to write sizeof struct trie_node_f to n in %s\n", "[udevadm-hwdb.c:trie_store_nodes]");
trie->nodes_count++;
/* append children array */
if (node->children_count) {
- fwrite(children, sizeof(struct trie_child_entry_f), node->children_count, trie->f);
+ if (fwrite(children, sizeof(struct trie_child_entry_f), node->children_count, trie->f) != node->children_count)
+ log_error("Failed to write children_count in %s\n", "[udevadm-hwdb.c:trie_store_nodes]");
trie->children_count += node->children_count;
free(children);
}
@@ -330,7 +332,8 @@ static int64_t trie_store_nodes(struct trie_f *trie, struct trie_node *node) {
.value_off = htole64(trie->strings_off + node->values[i].value_off),
};
- fwrite(&v, sizeof(struct trie_value_entry_f), 1, trie->f);
+ if (fwrite(&v, sizeof(struct trie_value_entry_f), 1, trie->f) != 1)
+ log_error("Failed to write sizeof trie_value_entry_f to v in %s\n", "[udevadm-hwdb.c:trie_store_nodes]");
trie->values_count++;
}
@@ -372,14 +375,16 @@ static int trie_store(struct trie *trie, const char *filename) {
h.nodes_len = htole64(pos - sizeof(struct trie_header_f));
/* write string buffer */
- fwrite(trie->strings->buf, trie->strings->len, 1, t.f);
+ if (fwrite(trie->strings->buf, trie->strings->len, 1, t.f) != 1)
+ log_error("Failed to write into trie->strings->buf in %s\n", "[udevadm-hwdb.c:trie_store]");
h.strings_len = htole64(trie->strings->len);
/* write header */
size = ftello(t.f);
h.file_size = htole64(size);
fseeko(t.f, 0, SEEK_SET);
- fwrite(&h, sizeof(struct trie_header_f), 1, t.f);
+ if (fwrite(&h, sizeof(struct trie_header_f), 1, t.f) != 1)
+ log_error("Failed to write into h in %s\n", "[udevadm-hwdb.c:trie_store]");
err = ferror(t.f);
if (err)
err = -errno;
diff --git a/src/udev/udevadm-settle.c b/src/udev/udevadm-settle.c
index c4fc4ee4e5..dd833fb6db 100644
--- a/src/udev/udevadm-settle.c
+++ b/src/udev/udevadm-settle.c
@@ -192,7 +192,8 @@ static int adm_settle(struct udev *udev, int argc, char *argv[])
if (poll(pfd, 1, delay) > 0 && pfd[0].revents & POLLIN) {
char buf[sizeof(struct inotify_event) + PATH_MAX];
- read(pfd[0].fd, buf, sizeof(buf));
+ if (read(pfd[0].fd, buf, sizeof(buf)) == -1)
+ log_error("Failed to read buf in %s\n", "[udevadm-settle:adm_settle]");
}
} else {
sleep(1);
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index b9922f51dd..bd650a1f6b 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -1157,7 +1157,11 @@ int main(int argc, char *argv[])
}
/* set umask before creating any file/directory */
- chdir("/");
+ if (chdir("/") == -1) {
+ fprintf(stderr, "Cannot chdir to /\n");
+ log_error("Cannot chdir to /\n");
+ goto exit;
+ }
umask(022);
mkdir("/run/udev", 0755);