From f934c17c6e63e69e91fdaf24631800c8cf8f84f5 Mon Sep 17 00:00:00 2001 From: Chris Kuethe Date: Mon, 4 Jun 2007 05:06:34 +0000 Subject: don't return NULL when passed a NULL pointer or a zero-length buffer; instead, return an empty string. this sort of thing happens when we call gpsd_hexdump inside one of the packet writers when we are about to write a packet with no payload. Printing a NULL pointer is rather ugly... printing an empty string is much prettier and consistent with the SQUELCH case. --- hex.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'hex.c') diff --git a/hex.c b/hex.c index cc22da79..4bbc950e 100644 --- a/hex.c +++ b/hex.c @@ -17,8 +17,8 @@ char /*@ observer @*/ *gpsd_hexdump(const void *binbuf, size_t binbuflen) const char *ibuf = (const char *)binbuf; const char *hexchar = "0123456789abcdef"; - if (NULL == binbuf) - return NULL; + if (NULL == binbuf || 0 == binbuflen) + return ""; /*@ -shiftimplementation @*/ for (i = 0; i < len; i++) { -- cgit v1.2.1