Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/rtadvd Lack of timeout is a programmin...



details:   https://anonhg.NetBSD.org/src/rev/679575d05b81
branches:  trunk
changeset: 318392:679575d05b81
user:      roy <roy%NetBSD.org@localhost>
date:      Fri Apr 20 16:07:48 2018 +0000
description:
Lack of timeout is a programming error, so use an assert in it's place.
While here, improve the error reported if malloc fails.

diffstat:

 usr.sbin/rtadvd/timer.c |  13 +++++--------
 1 files changed, 5 insertions(+), 8 deletions(-)

diffs (40 lines):

diff -r 1552ce941b5a -r 679575d05b81 usr.sbin/rtadvd/timer.c
--- a/usr.sbin/rtadvd/timer.c   Fri Apr 20 15:59:17 2018 +0000
+++ b/usr.sbin/rtadvd/timer.c   Fri Apr 20 16:07:48 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: timer.c,v 1.17 2018/04/20 15:59:17 roy Exp $   */
+/*     $NetBSD: timer.c,v 1.18 2018/04/20 16:07:48 roy Exp $   */
 /*     $KAME: timer.c,v 1.11 2005/04/14 06:22:35 suz Exp $     */
 
 /*
@@ -33,6 +33,7 @@
 #include <sys/queue.h>
 #include <sys/time.h>
 
+#include <assert.h>
 #include <limits.h>
 #include <unistd.h>
 #include <syslog.h>
@@ -63,19 +64,15 @@
 {
        struct rtadvd_timer *newtimer;
 
+       assert(timeout != NULL);
+
        if ((newtimer = malloc(sizeof(*newtimer))) == NULL) {
-               logit(LOG_ERR,
-                      "<%s> can't allocate memory", __func__);
+               logit(LOG_ERR, "%s: malloc: %m", __func__);
                exit(EXIT_FAILURE);
        }
 
        memset(newtimer, 0, sizeof(*newtimer));
 
-       if (timeout == NULL) {
-               logit(LOG_ERR,
-                      "<%s> timeout function unspecified", __func__);
-               exit(EXIT_FAILURE);
-       }
        newtimer->expire = timeout;
        newtimer->update = update;
        newtimer->expire_data = timeodata;



Home | Main Index | Thread Index | Old Index