diff options
author | Chris Kuethe <chris.kuethe@gmail.com> | 2007-06-04 05:06:34 +0000 |
---|---|---|
committer | Chris Kuethe <chris.kuethe@gmail.com> | 2007-06-04 05:06:34 +0000 |
commit | f934c17c6e63e69e91fdaf24631800c8cf8f84f5 (patch) | |
tree | c88ae609f87b42cef3ac4ee7a7e99c4dbfaede52 /hex.c | |
parent | 0a432496c594fa8d5eed6e69c069959113355bf9 (diff) | |
download | gpsd-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.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -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++) { |