1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
Description: Fix build warnings in smemcap
Build warnings occur for syscalls not handled properly by
evaluating the return.
Evaluate return with exit on failure.
Author: Steffen Kothe <steffen.kothe@skothe.net>
Forwarded: no
Index: smem/smemcap.c
===================================================================
--- smem.orig/smemcap.c 2025-08-31 11:35:44.494884240 +0000
+++ smem/smemcap.c 2025-08-31 11:36:01.138736602 +0000
@@ -75,7 +75,11 @@
/* dump file contents */
for (cur = start; size > 0; size -= 512) {
- write(destfd, cur->data, 512);
+ if ( 512 != write(destfd, cur->data, 512))
+ {
+ fprintf(stderr, "Dump of file content failed!\n");
+ exit(EXIT_FAILURE);
+ }
start = cur;
cur = cur->next;
free(start);
@@ -94,8 +98,14 @@
DIR *d;
struct dirent *de;
struct stat s;
+ int ret;
- chdir("/proc");
+ ret = chdir("/proc");
+ if (ret < 0)
+ {
+ fprintf(stderr, "Changing dir to /proc failed\n");
+ exit(EXIT_FAILURE);
+ }
archivefile("meminfo", 1);
archivefile("version", 1);
|