gpsd-dev
[Top][All Lists]
Advanced

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

[gpsd-dev] [PATCH 2/6] bzero() is gone in POSIX 2008. Use memset()


From: Fred Wright
Subject: [gpsd-dev] [PATCH 2/6] bzero() is gone in POSIX 2008. Use memset()
Date: Mon, 5 Sep 2016 18:09:24 -0700

This is the bzero() fix from commit 6692860, without the other
_DEFAULT_SOURCE hacks.

TESTED:
Ran "scons build-all check" successfully on OSX, Linux, FreeBSD,
OpenBSD, and NetBSD.
---
 contrib/binlog.c    | 2 +-
 contrib/motosend.c  | 6 +++---
 driver_garmin_txt.c | 4 ++--
 driver_sirf.c       | 2 +-
 gpspipe.c           | 2 +-
 5 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/contrib/binlog.c b/contrib/binlog.c
index 8e5e8d9..3093732 100644
--- a/contrib/binlog.c
+++ b/contrib/binlog.c
@@ -62,7 +62,7 @@ int main(int argc, char **argv) {
                if (l > 0)
                    assert(write(ofd, buf, l) > 0);
                usleep(1000);
-               bzero(buf, BUFSIZ);
+               memset(buf, 0, BUFSIZ);
                spinner( n++ );
        }
        /* NOTREACHED */
diff --git a/contrib/motosend.c b/contrib/motosend.c
index 3073158..0778fda 100644
--- a/contrib/motosend.c
+++ b/contrib/motosend.c
@@ -83,7 +83,7 @@ int main(int argc, char **argv) {
        t = 0; n = 0;
        while (1){
                usleep(1000);
-               bzero(buf, BSIZ);
+               memset(buf, 0, BSIZ);
                if ((l = read(fd, buf, BSIZ)) == -1)
                        if (!(EINTR == errno || EAGAIN == errno))
                                err(1, "read");
@@ -121,7 +121,7 @@ static int moto_send(int fd, char *type, char *body ) {
        if ((buf = malloc(l+7)) == NULL)
                return -1;
 
-       bzero(buf, l+7);
+       memset(buf, 0, l+7);
        buf[0] = '@'; buf[1] = '@';
        buf[2] = type[0]; buf[3] = type[1];
 
@@ -174,7 +174,7 @@ int gpsd_hexpack(char *src, char *dst, int len)
     if ((l < 1) || (l > len))
        return -1;
 
-    bzero(dst, len);
+    memset(dst, 0, len);
     for (i = 0; i < l; i++) {
        int k;
        if ((k = hex2bin(src+i*2)) != -1)
diff --git a/driver_garmin_txt.c b/driver_garmin_txt.c
index 8631ee3..c14c516 100644
--- a/driver_garmin_txt.c
+++ b/driver_garmin_txt.c
@@ -155,7 +155,7 @@ static int gar_decode(const struct gps_context_t *context,
        return -1;
     }
 
-    bzero(buf, (int)sizeof(buf));
+    memset(buf, 0, (int)sizeof(buf));
     (void)strlcpy(buf, data, length);
     gpsd_log(&context->errout, LOG_RAW + 2, "Decoded string: %s\n", buf);
 
@@ -223,7 +223,7 @@ static int gar_int_decode(const struct gps_context_t 
*context,
        return -1;
     }
 
-    bzero(buf, (int)sizeof(buf));
+    memset(buf, 0, (int)sizeof(buf));
     (void)strlcpy(buf, data, length);
     gpsd_log(&context->errout, LOG_RAW + 2, "Decoded string: %s\n", buf);
 
diff --git a/driver_sirf.c b/driver_sirf.c
index a377d7f..deec232 100644
--- a/driver_sirf.c
+++ b/driver_sirf.c
@@ -415,7 +415,7 @@ static gps_mask_t sirf_msg_debug(struct gps_device_t 
*device,
     char msgbuf[MAX_PACKET_LENGTH * 3 + 2];
     int i;
 
-    bzero(msgbuf, (int)sizeof(msgbuf));
+    memset(msgbuf, 0, (int)sizeof(msgbuf));
 
     if (0xe1 == buf[0]) {      /* Development statistics messages */
        for (i = 2; i < (int)len; i++)
diff --git a/gpspipe.c b/gpspipe.c
index 33d015c..a670581 100644
--- a/gpspipe.c
+++ b/gpspipe.c
@@ -77,7 +77,7 @@ static void open_serial(char *device)
     }
 
     /* Clear struct for new port settings. */
-    bzero(&newtio, sizeof(newtio));
+    memset(&newtio, 0, sizeof(newtio));
 
     /* make it raw */
     (void)cfmakeraw(&newtio);
-- 
2.9.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]