Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/wdogctl Fix fd leaks. Found by cppcheck.
details: https://anonhg.NetBSD.org/src/rev/bb60e242a3ad
branches: trunk
changeset: 760437:bb60e242a3ad
user: wiz <wiz%NetBSD.org@localhost>
date: Tue Jan 04 23:48:44 2011 +0000
description:
Fix fd leaks. Found by cppcheck.
diffstat:
sbin/wdogctl/wdogctl.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diffs (53 lines):
diff -r 70709aec2bf8 -r bb60e242a3ad sbin/wdogctl/wdogctl.c
--- a/sbin/wdogctl/wdogctl.c Tue Jan 04 23:46:34 2011 +0000
+++ b/sbin/wdogctl/wdogctl.c Tue Jan 04 23:48:44 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wdogctl.c,v 1.18 2009/03/16 13:37:45 lukem Exp $ */
+/* $NetBSD: wdogctl.c,v 1.19 2011/01/04 23:48:44 wiz Exp $ */
/*-
* Copyright (c) 2000 Zembu Labs, Inc.
@@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: wdogctl.c,v 1.18 2009/03/16 13:37:45 lukem Exp $");
+__RCSID("$NetBSD: wdogctl.c,v 1.19 2011/01/04 23:48:44 wiz Exp $");
#endif
@@ -200,6 +200,8 @@
if (ioctl(fd, WDOGIOC_SMODE, &wm) == -1)
err(EXIT_FAILURE, "WDOGIOC_SMODE");
+
+ (void)close(fd);
}
void
@@ -219,6 +221,8 @@
if (ioctl(fd, WDOGIOC_TICKLE) == -1)
syslog(LOG_EMERG, "unable to tickle watchdog timer %s: %m",
wm.wm_name);
+
+ (void)close(fd);
return;
}
@@ -316,6 +320,8 @@
err(EXIT_FAILURE, "open %s", _PATH_WATCHDOG);
if (ioctl(fd, WDOGIOC_TICKLE) == -1)
fprintf(stderr, "Cannot tickle timer\n");
+
+ (void)close(fd);
}
void
@@ -331,6 +337,7 @@
if (ioctl(fd, WDOGIOC_WHICH, &wm) == -1) {
printf("No watchdog timer running.\n");
+ (void)close(fd);
return;
}
mode = wm.wm_mode & WDOG_MODE_MASK;
Home |
Main Index |
Thread Index |
Old Index