]> sigrok.org Git - libsigrok.git/commitdiff
Fix log varargs bugs indicated by -Wformat
authorDaniel Elstner <redacted>
Sun, 13 Sep 2015 00:29:38 +0000 (02:29 +0200)
committerDaniel Elstner <redacted>
Sun, 13 Sep 2015 00:29:38 +0000 (02:29 +0200)
A few of these were pretty serious, like missing arguments,
passing integers where a string was expected, and so on.
In some places, change the types used by the code rather than
just the format strings.

25 files changed:
src/dmm/fs9922.c
src/dmm/vc870.c
src/hardware/baylibre-acme/api.c
src/hardware/baylibre-acme/gpio.c
src/hardware/baylibre-acme/protocol.c
src/hardware/brymen-bm86x/protocol.c
src/hardware/brymen-dmm/protocol.c
src/hardware/fx2lafw/dslogic.c
src/hardware/gmc-mh-1x-2x/protocol.c
src/hardware/hantek-dso/api.c
src/hardware/hung-chang-dso-2100/protocol.c
src/hardware/motech-lps-30x/protocol.c
src/hardware/pipistrello-ols/api.c
src/hardware/pipistrello-ols/protocol.c
src/hardware/rigol-ds/protocol.c
src/hardware/saleae-logic16/protocol.c
src/hwdriver.c
src/input/csv.c
src/input/input.c
src/output/output.c
src/scpi/scpi.c
src/scpi/scpi_tcp.c
src/scpi/scpi_vxi.c
src/serial.c
src/transform/transform.c

index 698e1184dd602d4b69b7c3405433fb97f33e8064..d2f6c6bfbcf7d7f7b83ca4062462802f121f4f82 100644 (file)
@@ -112,7 +112,9 @@ static int parse_value(const uint8_t *buf, float *result)
        } else if (!isdigit(buf[1]) || !isdigit(buf[2]) ||
                   !isdigit(buf[3]) || !isdigit(buf[4])) {
                sr_dbg("Value contained invalid digits: %02x %02x %02x %02x ("
-                      "%c %c %c %c).", buf[1], buf[2], buf[3], buf[4]);
+                       "%c %c %c %c).",
+                       buf[1], buf[2], buf[3], buf[4],
+                       buf[1], buf[2], buf[3], buf[4]);
                return SR_ERR;
        }
        intval = 0;
index 8b7f191f85c4fd8b7faffefca31cdefd2d5b9ee3..c50e24d7bed56a5179e2a55a72067b2df0b21028 100644 (file)
@@ -70,8 +70,9 @@ static int parse_value(const uint8_t *buf, struct vc870_info *info,
        } else if (!isdigit(buf[3]) || !isdigit(buf[4]) ||
                   !isdigit(buf[5]) || !isdigit(buf[6]) || !isdigit(buf[7])) {
                sr_dbg("Invalid digits: %02x %02x %02x %02x %02X "
-                      "(%c %c %c %c %c).", buf[3], buf[4], buf[5], buf[6],
-                      buf[7]);
+                       "(%c %c %c %c %c).",
+                       buf[3], buf[4], buf[5], buf[6], buf[7],
+                       buf[3], buf[4], buf[5], buf[6], buf[7]);
                return SR_ERR;
        }
 
index b1884b62b15aa0bbef0d2ab6697abb4286291292..6b3b43e483126cd8097b222c3480b9b2c1200342 100644 (file)
@@ -421,7 +421,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
        sr_session_send(sdi, &packet);
 
        if (devc->samples_missed > 0)
-               sr_warn("%d samples missed", devc->samples_missed);
+               sr_warn("%" PRIu64 " samples missed", devc->samples_missed);
 
        return SR_OK;
 }
index c2e6da9d7fce8a715228b639bda3ac3714026f4e..93daff7b2636425bf1bd8418609c72e8ba19f110 100644 (file)
@@ -125,7 +125,7 @@ SR_PRIV int sr_gpio_get_value(int gpio)
        status = fscanf(fd, "%d", &ret);
        fclose(fd);
        if (status != 1) {
-               sr_err("Error reading from %s: %s", path, g_strerror(errno));
+               sr_err("Error reading from %s: %s", path->str, g_strerror(errno));
                g_string_free(path, TRUE);
                return -1;
        }
index a50c221993bd31852a57bd5ddac404c14fcea41e..cba1f7c0edb7f2caee2f70649f88fbf79f1b164d 100644 (file)
@@ -507,7 +507,7 @@ static float read_sample(struct sr_channel *ch)
 
        len = read(fd, buf, sizeof(buf));
        if (len < 0) {
-               sr_err("Error reading from channel %s (hwmon: %s): %s",
+               sr_err("Error reading from channel %s (hwmon: %d): %s",
                        ch->name, chp->probe->hwmon_num, g_strerror(errno));
                ch->enabled = FALSE;
                return -1.0;
index 4de8a74cf6bdc7ffd6e4b4124d32292544e1be00..74101518ce25fe6401a2571adc6b44a4ac17b336 100644 (file)
@@ -293,7 +293,7 @@ static int brymen_bm86x_read_interrupt(const struct sr_dev_inst *sdi)
        }
 
        if (transferred != sizeof(buf)) {
-               sr_err("Short packet: received %d/%d bytes.", transferred, sizeof(buf));
+               sr_err("Short packet: received %d/%zu bytes.", transferred, sizeof(buf));
                return SR_ERR;
        }
 
index 5fb5ec29cb4c6cbfdcb87ffeb3bcb1b485a6bf3d..02e14d3198fd6e0a75bd6eba45160e8da8b102ab 100644 (file)
@@ -179,7 +179,9 @@ SR_PRIV int brymen_stream_detect(struct sr_serial_dev_inst *serial,
 {
        int64_t start, time, byte_delay_us;
        size_t ibuf, i, maxlen;
-       int status, len, packet_len, stream_len;
+       ssize_t len, stream_len;
+       int packet_len;
+       int status;
 
        maxlen = *buflen;
 
@@ -195,7 +197,7 @@ SR_PRIV int brymen_stream_detect(struct sr_serial_dev_inst *serial,
                len = serial_read_nonblocking(serial, &buf[ibuf], maxlen - ibuf);
                if (len > 0) {
                        ibuf += len;
-                       sr_spew("Read %d bytes.", len);
+                       sr_spew("Read %zd bytes.", len);
                }
 
                time = g_get_monotonic_time() - start;
@@ -247,14 +249,14 @@ SR_PRIV int brymen_stream_detect(struct sr_serial_dev_inst *serial,
 
                if (time >= (int64_t)timeout_ms) {
                        /* Timeout */
-                       sr_dbg("Detection timed out after %dms.", time);
+                       sr_dbg("Detection timed out after %" PRIi64 "ms.", time);
                        break;
                }
                g_usleep(byte_delay_us);
        }
 
        *buflen = ibuf;
-       sr_err("Didn't find a valid packet (read %d bytes).", ibuf);
+       sr_err("Didn't find a valid packet (read %zu bytes).", ibuf);
 
        return SR_ERR;
 }
index b1cbac096b5533f4031950ffd62a7005043b12d6..5d543ada237cc62d509a381508a455f5f7416ef6 100644 (file)
@@ -38,7 +38,7 @@ int dslogic_fpga_firmware_upload(const struct sr_dev_inst *sdi,
                const char *filename)
 {
        FILE *fw;
-       struct stat st;
+       GStatBuf st;
        struct sr_usb_dev_inst *usb;
        int chunksize, result, ret;
        unsigned char *buf;
@@ -48,7 +48,7 @@ int dslogic_fpga_firmware_upload(const struct sr_dev_inst *sdi,
        sr_dbg("Uploading FPGA firmware at %s.", filename);
 
        usb = sdi->conn;
-       if (stat(filename, &st) < 0) {
+       if (g_stat(filename, &st) < 0) {
                sr_err("Unable to upload FPGA firmware: %s", g_strerror(errno));
                return SR_ERR;
        }
@@ -85,7 +85,8 @@ int dslogic_fpga_firmware_upload(const struct sr_dev_inst *sdi,
                        break;
                }
                sum += transferred;
-               sr_spew("Uploaded %d/%d bytes.", sum, st.st_size);
+               sr_spew("Uploaded %d/%" PRIu64 " bytes.",
+                       sum, (uint64_t)st.st_size);
 
                if (transferred != chunksize) {
                        sr_err("Short transfer while uploading FPGA firmware.");
index 63ed2572f313288ec66ce168c9c82f9b956bfb4c..6cd8694fb55603547da9d6a62549e04b87abb1e1 100644 (file)
@@ -856,7 +856,7 @@ static void process_msg_inf_13(struct sr_dev_inst *sdi)
                devc->value += pow(10.0, cnt) * dgt;
        }
        sr_spew("process_msg_inf_13() value=%f scale=%f scale1000=%d mq=%d "
-               "unit=%d mqflags=0x%02llx", devc->value, devc->scale,
+               "unit=%d mqflags=0x%02" PRIx64, devc->value, devc->scale,
                devc->scale1000, devc->mq, devc->unit, devc->mqflags);
        if (devc->value != NAN)
                devc->value *= devc->scale * pow(1000.0, devc->scale1000);
@@ -1002,7 +1002,7 @@ SR_PRIV int process_msg14(struct sr_dev_inst *sdi)
                sr_spew("Cmd %d unimplemented!", devc->buf[3]);
                break;
        case 3: /* Read firmware version and status */
-               sr_spew("Cmd 3, Read firmware and status", devc->buf[3]);
+               sr_spew("Cmd 3, Read firmware and status");
                switch (devc->cmd_idx) {
                case 0:
                        devc->fw_ver_maj = devc->buf[5];
@@ -1073,7 +1073,7 @@ SR_PRIV int process_msg14(struct sr_dev_inst *sdi)
                        devc->value += pow(10.0, cnt) * dgt;
                }
                sr_spew("process_msg14() value=%f scale=%f scale1000=%d mq=%d "
-                       "unit=%d mqflags=0x%02llx", devc->value, devc->scale,
+                       "unit=%d mqflags=0x%02" PRIx64, devc->value, devc->scale,
                        devc->scale1000, devc->mq, devc->unit, devc->mqflags);
                if (devc->value != NAN)
                        devc->value *= devc->scale * pow(1000.0, devc->scale1000);
index b871ddaf11c3f453757d13b16f05b0527dd39ff3..90706065f4154c37ae1d228b0ecec535ceb13101 100644 (file)
@@ -394,7 +394,7 @@ static int dev_open(struct sr_dev_inst *sdi)
                        timediff_ms = timediff_us / 1000;
                        sr_spew("Waited %" PRIi64 " ms.", timediff_ms);
                }
-               sr_info("Device came back after %d ms.", timediff_ms);
+               sr_info("Device came back after %" PRIi64 " ms.", timediff_ms);
        } else {
                err = dso_open(sdi);
        }
index 6f997db020389ed30d8abdaee0c05651ecc19c84..022fac7ec456983e2c15edffd6d2783879af6d0f 100644 (file)
@@ -434,7 +434,7 @@ SR_PRIV int hung_chang_dso_2100_poll(int fd, int revents, void *cb_data)
                return TRUE;
 
        if (state != 0x03) {
-               sr_err("Unexpected state 0x%X while checking for trigger");
+               sr_err("Unexpected state 0x%X while checking for trigger", state);
                return FALSE;
        }
 
index 751d2d261a3df742033922916fbb68557571808b..c7f65e1001fc33b5015febadbaf9f2f428f1557d 100644 (file)
@@ -193,9 +193,10 @@ SR_PRIV int motech_lps_30x_receive_data(int fd, int revents, void *cb_data)
                return TRUE;
 
        if (devc->acq_req_pending) {
-               gint64 elapsed_us = g_get_monotonic_time() - devc->req_sent_at;
+               int64_t elapsed_us = g_get_monotonic_time() - devc->req_sent_at;
                if (elapsed_us > (REQ_TIMEOUT_MS * 1000)) {
-                       sr_spew("Request timeout: req=%d t=%lldus", (int)devc->acq_req, elapsed_us);
+                       sr_spew("Request timeout: req=%d t=%" PRIi64 "us",
+                               (int)devc->acq_req, elapsed_us);
                        devc->acq_req_pending = 0;
                }
        }
index 03cda60b165846450fca7bfcac60681f78a7689d..c5c53ce82f3a8e57828b895a9962ec50527edfac 100644 (file)
@@ -576,7 +576,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
         * buffer.
         */
        sr_dbg("max_samples = %d", devc->max_samples);
-       sr_dbg("limit_samples = %d", devc->limit_samples);
+       sr_dbg("limit_samples = %" PRIu64, devc->limit_samples);
        samplecount = MIN(devc->max_samples, devc->limit_samples);
        sr_dbg("Samplecount = %d", samplecount);
 
index ec588b41563b4aba7bc5074945e2bd036912d7dd..3db3aa4b5eaf01d9a6f04f061fc5c4499084fa8c 100644 (file)
@@ -505,7 +505,9 @@ SR_PRIV int p_ols_receive_data(int fd, int revents, void *cb_data)
                                        }
                                        /* Clear out the most significant bit of the sample */
                                        devc->tmp_sample[devc->num_bytes - 1] &= 0x7f;
-                                       sr_spew("Expanded sample 1: 0x%.8x.", devc->tmp_sample);
+                                       sr_spew("Expanded sample 1: 0x%.2x%.2x%.2x%.2x.",
+                                               devc->tmp_sample[3], devc->tmp_sample[2],
+                                               devc->tmp_sample[1], devc->tmp_sample[0]);
 
                                        /* expand second sample */
                                        memset(devc->tmp_sample2, 0, 4);
@@ -521,7 +523,9 @@ SR_PRIV int p_ols_receive_data(int fd, int revents, void *cb_data)
                                        }
                                        /* Clear out the most significant bit of the sample */
                                        devc->tmp_sample2[devc->num_bytes - 1] &= 0x7f;
-                                       sr_spew("Expanded sample 2: 0x%.8x.", devc->tmp_sample2);
+                                       sr_spew("Expanded sample 2: 0x%.2x%.2x%.2x%.2x.",
+                                               devc->tmp_sample2[3], devc->tmp_sample2[2],
+                                               devc->tmp_sample2[1], devc->tmp_sample2[0]);
 
                                        /*
                                         * OLS sends its sample buffer backwards.
index 35ec618461c57eb1cfca134149bab2a9ea9615d2..06dc1a3e3a0c73f7ad12f93b2124de0620d03738 100644 (file)
@@ -712,7 +712,8 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
                }
                devc->num_block_read = 0;
        } else {
-               sr_dbg("%d of %d block bytes read", devc->num_block_read, devc->num_block_bytes);
+               sr_dbg("%" PRIu64 " of %" PRIu64 " block bytes read",
+                       devc->num_block_read, devc->num_block_bytes);
        }
 
        devc->num_channel_bytes += len;
index 5e43c3bd45903014d8175be0c49b665c9b4b1f4a..6858215c1750c53fc7c28f75b9d5ecfe72029263 100644 (file)
@@ -214,7 +214,7 @@ static int do_ep1_command(const struct sr_dev_inst *sdi,
        }
        if (xfer != cmd_len) {
                sr_dbg("Failed to send EP1 command 0x%02x: incorrect length "
-                      "%d != %d.", xfer, cmd_len);
+                      "%d != %d.", command[0], xfer, cmd_len);
                return SR_ERR;
        }
 
@@ -230,7 +230,7 @@ static int do_ep1_command(const struct sr_dev_inst *sdi,
        }
        if (xfer != reply_len) {
                sr_dbg("Failed to receive reply to EP1 command 0x%02x: "
-                      "incorrect length %d != %d.", xfer, reply_len);
+                      "incorrect length %d != %d.", command[0], xfer, reply_len);
                return SR_ERR;
        }
 
index fe8ac457f7009c477da83c83ff22fb74b318d65b..0700276cb84db77f39ebdd0ee6e88ca5be9d89c7 100644 (file)
@@ -602,7 +602,7 @@ static int check_key(const struct sr_dev_driver *driver,
 
        if (sr_config_list(driver, sdi, cg, SR_CONF_DEVICE_OPTIONS, &gvar_opts) != SR_OK) {
                /* Driver publishes no options. */
-               sr_err("No options available%s.", srci->id, suffix);
+               sr_err("No options available%s.", suffix);
                return SR_ERR_ARG;
        }
        opts = g_variant_get_fixed_array(gvar_opts, &num_opts, sizeof(uint32_t));
index cc09045aa281919a88580e681149724c7519300f..0a2d7276d996eb14b5f0310999feb1ed2e3c8c06 100644 (file)
@@ -80,7 +80,7 @@ struct context {
        uint64_t samplerate;
 
        /* Number of channels. */
-       gsize num_channels;
+       unsigned int num_channels;
 
        /* Column delimiter character(s). */
        GString *delimiter;
@@ -95,23 +95,23 @@ struct context {
        gboolean multi_column_mode;
 
        /* Column number of the sample data in single column mode. */
-       gsize single_column;
+       unsigned int single_column;
 
        /*
         * Number of the first column to parse. Equivalent to the number of the
         * first channel in multi column mode and the single column number in
         * single column mode.
         */
-       gsize first_column;
+       unsigned int first_column;
 
        /*
         * Column number of the first channel in multi column mode and position of
         * the bit for the first channel in single column mode.
         */
-       gsize first_channel;
+       unsigned int first_channel;
 
        /* Line number to start processing. */
-       gsize start_line;
+       size_t start_line;
 
        /*
         * Determines if the first line should be treated as header and used for
@@ -123,13 +123,13 @@ struct context {
        int format;
 
        /* Size of the sample buffer. */
-       gsize sample_buffer_size;
+       size_t sample_buffer_size;
 
        /* Buffer to store sample data. */
        uint8_t *sample_buffer;
 
        /* Current line number. */
-       gsize line_number;
+       size_t line_number;
 };
 
 static int format_match(GHashTable *metadata)
@@ -161,7 +161,7 @@ static int parse_binstr(const char *str, struct context *inc)
        length = strlen(str);
 
        if (!length) {
-               sr_err("Column %zu in line %zu is empty.", inc->single_column,
+               sr_err("Column %u in line %zu is empty.", inc->single_column,
                        inc->line_number);
                return SR_ERR;
        }
@@ -175,7 +175,7 @@ static int parse_binstr(const char *str, struct context *inc)
                if (str[length - i - 1] == '1') {
                        inc->sample_buffer[j / 8] |= (1 << (j % 8));
                } else if (str[length - i - 1] != '0') {
-                       sr_err("Invalid value '%s' in column %zu in line %zu.",
+                       sr_err("Invalid value '%s' in column %u in line %zu.",
                                str, inc->single_column, inc->line_number);
                        return SR_ERR;
                }
@@ -193,7 +193,7 @@ static int parse_hexstr(const char *str, struct context *inc)
        length = strlen(str);
 
        if (!length) {
-               sr_err("Column %zu in line %zu is empty.", inc->single_column,
+               sr_err("Column %u in line %zu is empty.", inc->single_column,
                        inc->line_number);
                return SR_ERR;
        }
@@ -208,7 +208,7 @@ static int parse_hexstr(const char *str, struct context *inc)
                c = str[length - i - 1];
 
                if (!g_ascii_isxdigit(c)) {
-                       sr_err("Invalid value '%s' in column %zu in line %zu.",
+                       sr_err("Invalid value '%s' in column %u in line %zu.",
                                str, inc->single_column, inc->line_number);
                        return SR_ERR;
                }
@@ -237,7 +237,7 @@ static int parse_octstr(const char *str, struct context *inc)
        length = strlen(str);
 
        if (!length) {
-               sr_err("Column %zu in line %zu is empty.", inc->single_column,
+               sr_err("Column %u in line %zu is empty.", inc->single_column,
                        inc->line_number);
                return SR_ERR;
        }
@@ -252,7 +252,7 @@ static int parse_octstr(const char *str, struct context *inc)
                c = str[length - i - 1];
 
                if (c < '0' || c > '7') {
-                       sr_err("Invalid value '%s' in column %zu in line %zu.",
+                       sr_err("Invalid value '%s' in column %u in line %zu.",
                                str, inc->single_column, inc->line_number);
                        return SR_ERR;
                }
@@ -437,7 +437,7 @@ static int init(struct sr_input *in, GHashTable *options)
 
        inc->start_line = g_variant_get_int32(g_hash_table_lookup(options, "startline"));
        if (inc->start_line < 1) {
-               sr_err("Invalid start line %d.", inc->start_line);
+               sr_err("Invalid start line %zu.", inc->start_line);
                return SR_ERR_ARG;
        }
 
@@ -473,8 +473,8 @@ static int initial_parse(const struct sr_input *in, GString *buf)
 {
        struct context *inc;
        GString *channel_name;
-       gsize num_columns, l, i;
-       unsigned int line_number;
+       unsigned int num_columns, i;
+       size_t line_number, l;
        int ret;
        char **lines, **columns;
 
@@ -522,7 +522,7 @@ static int initial_parse(const struct sr_input *in, GString *buf)
 
        /* Ensure that the first column is not out of bounds. */
        if (!num_columns) {
-               sr_err("Column %zu in line %zu is out of bounds.",
+               sr_err("Column %u in line %zu is out of bounds.",
                        inc->first_column, line_number);
                ret = SR_ERR;
                goto out;
@@ -535,7 +535,7 @@ static int initial_parse(const struct sr_input *in, GString *buf)
                 */
                if (!inc->num_channels) {
                        inc->num_channels = num_columns;
-                       sr_dbg("Number of auto-detected channels: %zu.",
+                       sr_dbg("Number of auto-detected channels: %u.",
                                inc->num_channels);
                }
 
@@ -553,10 +553,10 @@ static int initial_parse(const struct sr_input *in, GString *buf)
 
        channel_name = g_string_sized_new(64);
        for (i = 0; i < inc->num_channels; i++) {
-               if (inc->header && inc->multi_column_mode && strlen(columns[i]))
+               if (inc->header && inc->multi_column_mode && columns[i][0] != '\0')
                        g_string_assign(channel_name, columns[i]);
                else
-                       g_string_printf(channel_name, "%zu", i);
+                       g_string_printf(channel_name, "%u", i);
                sr_channel_new(in->sdi, i, SR_CHANNEL_LOGIC, TRUE, channel_name->str);
        }
        g_string_free(channel_name, TRUE);
@@ -679,7 +679,7 @@ static int process_buffer(struct sr_input *in)
                }
                num_columns = g_strv_length(columns);
                if (!num_columns) {
-                       sr_err("Column %zu in line %zu is out of bounds.",
+                       sr_err("Column %u in line %zu is out of bounds.",
                                inc->first_column, inc->line_number);
                        g_strfreev(columns);
                        return SR_ERR;
index 71604658809761444892d92cf625df2591408006..9bae0970a7ea4eb5446d7d7d7c70e40935ffe40a 100644 (file)
@@ -263,7 +263,8 @@ SR_API struct sr_input *sr_input_new(const struct sr_input_module *imod,
                                /* Option not given: insert the default value. */
                                gvt = g_variant_get_type(mod_opts[i].def);
                                if (!g_variant_is_of_type(value, gvt)) {
-                                       sr_err("Invalid type for '%s' option.", key);
+                                       sr_err("Invalid type for '%s' option.",
+                                               (char *)key);
                                        g_free(in);
                                        return NULL;
                                }
@@ -281,7 +282,8 @@ SR_API struct sr_input *sr_input_new(const struct sr_input_module *imod,
                        g_hash_table_iter_init(&iter, options);
                        while (g_hash_table_iter_next(&iter, &key, &value)) {
                                if (!g_hash_table_lookup(new_opts, key)) {
-                                       sr_err("Input module '%s' has no option '%s'", imod->id, key);
+                                       sr_err("Input module '%s' has no option '%s'",
+                                               imod->id, (char *)key);
                                        g_hash_table_destroy(new_opts);
                                        g_free(in);
                                        return NULL;
@@ -549,7 +551,8 @@ SR_API struct sr_dev_inst *sr_input_dev_inst_get(const struct sr_input *in)
  */
 SR_API int sr_input_send(const struct sr_input *in, GString *buf)
 {
-       sr_spew("Sending %d bytes to %s module.", buf->len, in->module->id);
+       sr_spew("Sending %" G_GSIZE_FORMAT " bytes to %s module.",
+               buf->len, in->module->id);
        return in->module->receive((struct sr_input *)in, buf);
 }
 
@@ -583,7 +586,8 @@ SR_API void sr_input_free(const struct sr_input *in)
                sr_dev_inst_free(in->sdi);
        if (in->buf->len > 64) {
                /* That seems more than just some sub-unitsize leftover... */
-               sr_warn("Found %d unprocessed bytes at free time.", in->buf->len);
+               sr_warn("Found %" G_GSIZE_FORMAT
+                       " unprocessed bytes at free time.", in->buf->len);
        }
        g_string_free(in->buf, TRUE);
        g_free(in->priv);
index 0a9e7f880689bee89308cd9e30dd4e8b9075fce7..df22b22233720cc349b4bb88cc0c5b12ee33913a 100644 (file)
@@ -283,7 +283,8 @@ SR_API const struct sr_output *sr_output_new(const struct sr_output_module *omod
                                /* Pass option along. */
                                gvt = g_variant_get_type(mod_opts[i].def);
                                if (!g_variant_is_of_type(value, gvt)) {
-                                       sr_err("Invalid type for '%s' option.", key);
+                                       sr_err("Invalid type for '%s' option.",
+                                               (char *)key);
                                        g_free(op);
                                        return NULL;
                                }
@@ -301,7 +302,8 @@ SR_API const struct sr_output *sr_output_new(const struct sr_output_module *omod
                        g_hash_table_iter_init(&iter, options);
                        while (g_hash_table_iter_next(&iter, &key, &value)) {
                                if (!g_hash_table_lookup(new_opts, key)) {
-                                       sr_err("Output module '%s' has no option '%s'", omod->id, key);
+                                       sr_err("Output module '%s' has no option '%s'",
+                                               omod->id, (char *)key);
                                        g_hash_table_destroy(new_opts);
                                        g_free(op);
                                        return NULL;
index 38d74ab5ffcc17989d478e9a9cb93fcf3c9877a0..e198b2bd296579d5fe89d14baf59c131489dae65 100644 (file)
@@ -425,10 +425,10 @@ SR_PRIV int sr_scpi_get_string(struct sr_scpi_dev_inst *scpi,
        if (response->len >= 1 && response->str[response->len - 1] == '\r')
                g_string_truncate(response, response->len - 1);
 
-       *scpi_response = response->str;
-       g_string_free(response, FALSE);
+       sr_spew("Got response: '%.70s', length %" G_GSIZE_FORMAT ".",
+               response->str, response->len);
 
-       sr_spew("Got response: '%.70s', length %d.", *scpi_response, strlen(*scpi_response));
+       *scpi_response = g_string_free(response, FALSE);
 
        return SR_OK;
 }
index cf01c905cf65f8bfa4745275bbe820e15bbb0edc..14a2d2cb7b3a226fbfd2bd7778bdc3ac3eb99df6 100644 (file)
@@ -86,7 +86,7 @@ static int scpi_tcp_open(void *priv)
        err = getaddrinfo(tcp->address, tcp->port, &hints, &results);
 
        if (err) {
-               sr_err("Address lookup failed: %s:%d: %s", tcp->address, tcp->port,
+               sr_err("Address lookup failed: %s:%s: %s", tcp->address, tcp->port,
                        gai_strerror(err));
                return SR_ERR;
        }
index b2324b71be96b70646122627ca9e43aec9a73cc5..cef0cf0beddcd2ac74e0ddba09f59fe553964147 100644 (file)
@@ -118,7 +118,7 @@ static int scpi_vxi_send(void *priv, const char *command)
        Device_WriteResp *write_resp;
        Device_WriteParms write_parms;
        char *terminated_command;
-       unsigned int len;
+       unsigned long len;
 
        terminated_command = g_strdup_printf("%s\r\n", command);
        len = strlen(terminated_command);
@@ -132,7 +132,7 @@ static int scpi_vxi_send(void *priv, const char *command)
 
        if (!(write_resp = device_write_1(&write_parms, vxi->client))
            || write_resp->error) {
-               sr_err("Device write failed for %s with error %d",
+               sr_err("Device write failed for %s with error %ld",
                       vxi->address, write_resp ? write_resp->error : 0);
                return SR_ERR;
        }
@@ -140,7 +140,7 @@ static int scpi_vxi_send(void *priv, const char *command)
        g_free(terminated_command);
 
        if (write_resp->size < len)
-               sr_dbg("Only sent %d/%d bytes of SCPI command: '%s'.",
+               sr_dbg("Only sent %lu/%lu bytes of SCPI command: '%s'.",
                       write_resp->size, len, command);
        else
                sr_spew("Successfully sent SCPI command: '%s'.", command);
@@ -177,7 +177,7 @@ static int scpi_vxi_read_data(void *priv, char *buf, int maxlen)
 
        if (!(read_resp = device_read_1(&read_parms, vxi->client))
            || read_resp->error) {
-               sr_err("Device read failed for %s with error %d",
+               sr_err("Device read failed for %s with error %ld",
                       vxi->address, read_resp ? read_resp->error : 0);
                return SR_ERR;
        }
index b0ae07f083503ee5a615627528fdb467c223cbb6..d9c611bd1164e401a16fc554fc3e29d7304f3eda 100644 (file)
@@ -267,7 +267,7 @@ static int _serial_write(struct sr_serial_dev_inst *serial,
                return SR_ERR;
        }
 
-       sr_spew("Wrote %d/%d bytes.", ret, count);
+       sr_spew("Wrote %zd/%zu bytes.", ret, count);
 
        return ret;
 }
@@ -345,7 +345,7 @@ static int _serial_read(struct sr_serial_dev_inst *serial, void *buf,
        }
 
        if (ret > 0)
-               sr_spew("Read %d/%d bytes.", ret, count);
+               sr_spew("Read %zd/%zu bytes.", ret, count);
 
        return ret;
 }
@@ -683,7 +683,7 @@ SR_PRIV int serial_stream_detect(struct sr_serial_dev_inst *serial,
 {
        uint64_t start, time, byte_delay_us;
        size_t ibuf, i, maxlen;
-       int len;
+       ssize_t len;
 
        maxlen = *buflen;
 
@@ -716,12 +716,12 @@ SR_PRIV int serial_stream_detect(struct sr_serial_dev_inst *serial,
                if ((ibuf - i) >= packet_size) {
                        /* We have at least a packet's worth of data. */
                        if (is_valid(&buf[i])) {
-                               sr_spew("Found valid %d-byte packet after "
+                               sr_spew("Found valid %zu-byte packet after "
                                        "%" PRIu64 "ms.", (ibuf - i), time);
                                *buflen = ibuf;
                                return SR_OK;
                        } else {
-                               sr_spew("Got %d bytes, but not a valid "
+                               sr_spew("Got %zu bytes, but not a valid "
                                        "packet.", (ibuf - i));
                        }
                        /* Not a valid packet. Continue searching. */
@@ -729,7 +729,7 @@ SR_PRIV int serial_stream_detect(struct sr_serial_dev_inst *serial,
                }
                if (time >= timeout_ms) {
                        /* Timeout */
-                       sr_dbg("Detection timed out after %dms.", time);
+                       sr_dbg("Detection timed out after %" PRIu64 "ms.", time);
                        break;
                }
                if (len < 1)
@@ -738,7 +738,7 @@ SR_PRIV int serial_stream_detect(struct sr_serial_dev_inst *serial,
 
        *buflen = ibuf;
 
-       sr_err("Didn't find a valid packet (read %d bytes).", *buflen);
+       sr_err("Didn't find a valid packet (read %zu bytes).", *buflen);
 
        return SR_ERR;
 }
index b518088bd8e625f438f1f32d02fd576209651494..f8ae7970b9b2b464a385b8ba5bc6b881937d7a65 100644 (file)
@@ -221,7 +221,8 @@ SR_API const struct sr_transform *sr_transform_new(const struct sr_transform_mod
                                /* Pass option along. */
                                gvt = g_variant_get_type(mod_opts[i].def);
                                if (!g_variant_is_of_type(value, gvt)) {
-                                       sr_err("Invalid type for '%s' option.", key);
+                                       sr_err("Invalid type for '%s' option.",
+                                               (char *)key);
                                        g_free(t);
                                        return NULL;
                                }
@@ -239,7 +240,8 @@ SR_API const struct sr_transform *sr_transform_new(const struct sr_transform_mod
                        g_hash_table_iter_init(&iter, options);
                        while (g_hash_table_iter_next(&iter, &key, &value)) {
                                if (!g_hash_table_lookup(new_opts, key)) {
-                                       sr_err("Transform module '%s' has no option '%s'.", tmod->id, key);
+                                       sr_err("Transform module '%s' has no option '%s'.",
+                                               tmod->id, (char *)key);
                                        g_hash_table_destroy(new_opts);
                                        g_free(t);
                                        return NULL;