gpsd-dev
[Top][All Lists]
Advanced

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

Fw: [Git][gpsd/gpsd][master] 2 commits: serial.c: Fix some warnings.


From: Gary E. Miller
Subject: Fw: [Git][gpsd/gpsd][master] 2 commits: serial.c: Fix some warnings.
Date: Fri, 10 Sep 2021 11:21:53 -0700

Yo Fred!

- - - - -
699108bc by Fred Wright at 2021-09-10T00:37:27-07:00
gpsd.c: Fix an initializer warning.

Since devices is an array of structs, it needs extra braces in the
initializer to refer to a single element.

TESTED:
Warning is gone.


Yes, but the intent was to initialize the entire array, not just
a single element.

-static struct gps_device_t devices[MAX_DEVICES] = {0};
+static struct gps_device_t devices[MAX_DEVICES] = {{{0}}};

Since static forces devices to be all zeros, best to just do this:

static struct gps_device_t devices[MAX_DEVICES];

What compiler?  My understanding of the C standard is that {0} will
initialize anything to all zeros.  That is what gcc does.

RGDS
GARY
---------------------------------------------------------------------------
Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703
        gem@rellim.com  Tel:+1 541 382 8588

            Veritas liberabit vos. -- Quid est veritas?
    "If you can't measure it, you can't improve it." - Lord Kelvin

Fred Wright pushed to branch master at gpsd / gpsd

Commits:

2 changed files:

Changes:

  • gpsd/gpsd.c
    ... ... @@ -307,9 +307,9 @@ static socket_t filesock(char *filename)
    307 307
     /*
    
    308 308
      * This array fills from the bottom, so as an extreme case you can
    
    309 309
      * reduce MAX_DEVICES to 1 in the build recipe.
    
    310
    - * Yes, the "= {0}" is redundant to "static".
    
    310
    + * Yes, the "= {{{0}}}" is redundant with "static".
    
    311 311
      */
    
    312
    -static struct gps_device_t devices[MAX_DEVICES] = {0};
    
    312
    +static struct gps_device_t devices[MAX_DEVICES] = {{{0}}};
    
    313 313
     
    
    314 314
     static void adjust_max_fd(int fd, bool on)
    
    315 315
     /* track the largest fd currently in use */
    

  • gpsd/serial.c
    ... ... @@ -612,14 +612,14 @@ void gpsd_set_speed(struct gps_device_t *session,
    612 612
                          "SER: fd %d keeping old speed %d(%d)\n",
    
    613 613
                          session->gpsdata.gps_fd,
    
    614 614
                          code2speed(cfgetispeed(&session->ttyset)),
    
    615
    -                     cfgetispeed(&session->ttyset));
    
    615
    +                     (int) cfgetispeed(&session->ttyset));
    
    616 616
             } else {
    
    617 617
                 (void)cfsetispeed(&session->ttyset, rate);
    
    618 618
                 (void)cfsetospeed(&session->ttyset, rate);
    
    619 619
                 GPSD_LOG(LOG_IO, &session->context->errout,
    
    620 620
                          "SER: fd %d set speed %d(%d)\n",
    
    621 621
                          session->gpsdata.gps_fd,
    
    622
    -                     code2speed(cfgetispeed(&session->ttyset)), rate);
    
    622
    +                     code2speed(cfgetispeed(&session->ttyset)), (int) rate);
    
    623 623
             }
    
    624 624
             session->ttyset.c_iflag &= ~(PARMRK | INPCK);
    
    625 625
             session->ttyset.c_cflag &= ~(CSIZE | CSTOPB | PARENB | PARODD);
    
    ... ... @@ -884,7 +884,7 @@ int gpsd_serial_open(struct gps_device_t *session)
    884 884
                 GPSD_LOG(LOG_PROG, &session->context->errout,
    
    885 885
                          "SER: fd %d restoring fixed/saved speed %d(%d)\n",
    
    886 886
                          session->gpsdata.gps_fd, session->saved_baud,
    
    887
    -                     cfgetispeed(&session->ttyset));
    
    887
    +                     (int) cfgetispeed(&session->ttyset));
    
    888 888
             } else {
    
    889 889
                 GPSD_LOG(LOG_ERROR, &session->context->errout,
    
    890 890
                          "SER: fd %d Error setting port attributes: %s(%d)\n",
    

  • Attachment: pgpj_BtskKcYp.pgp
    Description: OpenPGP digital signature


    reply via email to

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