summaryrefslogtreecommitdiff
path: root/hwclock/hwclock.c
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2007-03-21 16:21:34 +0100
committerKarel Zak <kzak@redhat.com>2007-03-21 16:21:34 +0100
commit72bcf1898b3fb6ebb11f65a9b5b1980eafbc9c21 (patch)
treef54c69c32932b585c36ba1cc464bdf0a694d02fe /hwclock/hwclock.c
parent9abb26854c5f185683ba7bd812bb5076cedc8f0e (diff)
downloadutil-linux-old-72bcf1898b3fb6ebb11f65a9b5b1980eafbc9c21.tar.gz
hwclock: make ggc happy and check return values from fgets, read and write
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'hwclock/hwclock.c')
-rw-r--r--hwclock/hwclock.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/hwclock/hwclock.c b/hwclock/hwclock.c
index ee6309cb..4b4d3ee8 100644
--- a/hwclock/hwclock.c
+++ b/hwclock/hwclock.c
@@ -273,12 +273,12 @@ read_adjtime(struct adjtime *adjtime_p) {
char line3[81]; /* String: third line of adjtime file */
long timeval;
- line1[0] = '\0'; /* In case fgets fails */
- fgets(line1, sizeof(line1), adjfile);
- line2[0] = '\0'; /* In case fgets fails */
- fgets(line2, sizeof(line2), adjfile);
- line3[0] = '\0'; /* In case fgets fails */
- fgets(line3, sizeof(line3), adjfile);
+ if (!fgets(line1, sizeof(line1), adjfile))
+ line1[0] = '\0'; /* In case fgets fails */
+ if (!fgets(line2, sizeof(line2), adjfile))
+ line2[0] = '\0'; /* In case fgets fails */
+ if (!fgets(line3, sizeof(line3), adjfile))
+ line3[0] = '\0'; /* In case fgets fails */
fclose(adjfile);
@@ -627,8 +627,8 @@ interpret_date_string(const char *date_opt, time_t * const time_p) {
return 10;
}
- date_resp[0] = '\0'; /* in case fgets fails */
- fgets(date_resp, sizeof(date_resp), date_child_fp);
+ if (!fgets(date_resp, sizeof(date_resp), date_child_fp))
+ date_resp[0] = '\0'; /* in case fgets fails */
if (debug)
printf(_("response from date command = %s\n"), date_resp);
if (strncmp(date_resp, magic, sizeof(magic)-1) != 0) {
@@ -1296,7 +1296,7 @@ main(int argc, char **argv) {
struct timeval startup_time;
/* The time we started up, in seconds into the epoch, including
fractions. */
- time_t set_time; /* Time to which user said to set Hardware Clock */
+ time_t set_time = 0; /* Time to which user said to set Hardware Clock */
bool permitted; /* User is permitted to do the function */
int rc, c;