]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/strformat.c
Merge pull request #13649 from donaldsharp/unlock_the_node_or_else
[mirror_frr.git] / lib / strformat.c
index a420ba553a13b8f971c5e50790e2346722fc92ff..87d1715d262c9948bcf51bb124ca07f81678f8fa 100644 (file)
@@ -1,17 +1,6 @@
+// SPDX-License-Identifier: ISC
 /*
  * Copyright (c) 2019  David Lamparter, for NetDEF, Inc.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
 #ifdef HAVE_CONFIG_H
@@ -361,6 +350,8 @@ static ssize_t printfrr_abstime(struct fbuf *buf, struct printfrr_eargs *ea,
 
        if (flags & TIMEFMT_SKIP)
                return 0;
+       if (!ts)
+               return bputch(buf, '-');
 
        if (flags & TIMEFMT_REALTIME)
                *real_ts = *ts;
@@ -452,6 +443,8 @@ static ssize_t printfrr_reltime(struct fbuf *buf, struct printfrr_eargs *ea,
 
        if (flags & TIMEFMT_SKIP)
                return 0;
+       if (!ts)
+               return bputch(buf, '-');
 
        if (flags & TIMEFMT_ABSOLUTE) {
                struct timespec anchor[1];
@@ -561,8 +554,6 @@ static ssize_t printfrr_ts(struct fbuf *buf, struct printfrr_eargs *ea,
 {
        const struct timespec *ts = vptr;
 
-       if (!ts)
-               return bputs(buf, "(null)");
        return printfrr_time(buf, ea, ts, 0);
 }
 
@@ -574,7 +565,7 @@ static ssize_t printfrr_tv(struct fbuf *buf, struct printfrr_eargs *ea,
        struct timespec ts;
 
        if (!tv)
-               return bputs(buf, "(null)");
+               return printfrr_time(buf, ea, NULL, 0);
 
        ts.tv_sec = tv->tv_sec;
        ts.tv_nsec = tv->tv_usec * 1000;
@@ -589,7 +580,7 @@ static ssize_t printfrr_tt(struct fbuf *buf, struct printfrr_eargs *ea,
        struct timespec ts;
 
        if (!tt)
-               return bputs(buf, "(null)");
+               return printfrr_time(buf, ea, NULL, TIMEFMT_SECONDS);
 
        ts.tv_sec = *tt;
        ts.tv_nsec = 0;