summaryrefslogtreecommitdiff
path: root/hex.c
diff options
context:
space:
mode:
authorChris Kuethe <chris.kuethe@gmail.com>2007-06-04 05:06:34 +0000
committerChris Kuethe <chris.kuethe@gmail.com>2007-06-04 05:06:34 +0000
commitf934c17c6e63e69e91fdaf24631800c8cf8f84f5 (patch)
treec88ae609f87b42cef3ac4ee7a7e99c4dbfaede52 /hex.c
parent0a432496c594fa8d5eed6e69c069959113355bf9 (diff)
downloadgpsd-f934c17c6e63e69e91fdaf24631800c8cf8f84f5.tar.gz
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.
Diffstat (limited to 'hex.c')
-rw-r--r--hex.c4
1 files changed, 2 insertions, 2 deletions
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++) {