projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
src/common.[ch]: read_file_contents: Use {s,}size_t rather than int.
[collectd.git]
/
src
/
common.c
diff --git
a/src/common.c
b/src/common.c
index
d617832
..
79e4c02
100644
(file)
--- a/
src/common.c
+++ b/
src/common.c
@@
-1213,18
+1213,25
@@
int walk_directory (const char *dir, dirwalk_callback_f callback,
return (0);
}
return (0);
}
-
int read_file_contents (const char *filename, char *buf, in
t bufsize)
+
ssize_t read_file_contents (const char *filename, char *buf, size_
t bufsize)
{
FILE *fh;
{
FILE *fh;
-
int n
;
+
ssize_t ret
;
- if ((fh = fopen (filename, "r")) == NULL)
- return -1;
+ fh = fopen (filename, "r");
+ if (fh == NULL)
+ return (-1);
- n = fread(buf, 1, bufsize, fh);
- fclose(fh);
+ ret = (ssize_t) fread (buf, 1, bufsize, fh);
+ if ((ret == 0) && (ferror (fh) != 0))
+ {
+ ERROR ("read_file_contents: Reading file \"%s\" failed.",
+ filename);
+ ret = -1;
+ }
- return n;
+ fclose(fh);
+ return (ret);
}
counter_t counter_diff (counter_t old_value, counter_t new_value)
}
counter_t counter_diff (counter_t old_value, counter_t new_value)