]> sigrok.org Git - libsigrok.git/commitdiff
portability: Use g_strerror() in favor of strerror().
authorUwe Hermann <redacted>
Wed, 9 Sep 2015 07:16:58 +0000 (09:16 +0200)
committerUwe Hermann <redacted>
Wed, 9 Sep 2015 13:20:10 +0000 (15:20 +0200)
src/ezusb.c
src/hardware/baylibre-acme/gpio.c
src/hardware/baylibre-acme/protocol.c
src/hardware/fx2lafw/dslogic.c
src/hardware/motech-lps-30x/protocol.c
src/hardware/saleae-logic16/protocol.c
src/input/input.c
src/output/srzip.c
src/scpi/scpi_tcp.c
src/session_file.c

index 465dab0360f4c72f3e6b601ad43c264aaac0ed91..601c818bbf835bb35825030356f010dbc47af93e 100644 (file)
@@ -59,7 +59,7 @@ SR_PRIV int ezusb_install_firmware(libusb_device_handle *hdl,
        sr_info("Uploading firmware at %s", filename);
        if (!(fw = g_fopen(filename, "rb"))) {
                sr_err("Unable to open firmware file %s for reading: %s",
-                      filename, strerror(errno));
+                      filename, g_strerror(errno));
                return SR_ERR;
        }
 
index bb6c54d56fff3074fe1387cf645ba4da2e138ff2..c2e6da9d7fce8a715228b639bda3ac3714026f4e 100644 (file)
@@ -36,14 +36,14 @@ static int open_and_write(const gchar *path, const gchar *buf)
 
        fd = g_fopen(path, "w");
        if (!fd) {
-               sr_err("Error opening %s: %s", path, strerror(errno));
+               sr_err("Error opening %s: %s", path, g_strerror(errno));
                return -1;
        }
 
        wr = g_fprintf(fd, "%s", buf);
        fclose(fd);
        if (wr < 0) {
-               sr_err("Error writing to %s: %s", path, strerror(errno));
+               sr_err("Error writing to %s: %s", path, g_strerror(errno));
                return -1;
        }
 
@@ -117,7 +117,7 @@ SR_PRIV int sr_gpio_get_value(int gpio)
        g_string_printf(path, "/sys/class/gpio/gpio%d/value", gpio);
        fd = g_fopen(path->str, "r");
        if (!fd) {
-               sr_err("Error opening %s: %s", path->str, strerror(errno));
+               sr_err("Error opening %s: %s", path->str, g_strerror(errno));
                g_string_free(path, TRUE);
                return -1;
        }
@@ -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, strerror(errno));
+               sr_err("Error reading from %s: %s", path, g_strerror(errno));
                g_string_free(path, TRUE);
                return -1;
        }
index 8e730f15d0f26e5933512f86fa7da4cdddc3d4e6..a50c221993bd31852a57bd5ddac404c14fcea41e 100644 (file)
@@ -380,7 +380,7 @@ SR_PRIV int bl_acme_set_shunt(const struct sr_channel_group *cg, uint64_t shunt)
         */
        fd = g_fopen(path->str, "w");
        if (!fd) {
-               sr_err("Error opening %s: %s", path->str, strerror(errno));
+               sr_err("Error opening %s: %s", path->str, g_strerror(errno));
                ret = SR_ERR_IO;
                goto out;
        }
@@ -508,7 +508,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",
-                       ch->name, chp->probe->hwmon_num, strerror(errno));
+                       ch->name, chp->probe->hwmon_num, g_strerror(errno));
                ch->enabled = FALSE;
                return -1.0;
        }
@@ -540,7 +540,7 @@ SR_PRIV int bl_acme_open_channel(struct sr_channel *ch)
 
        fd = open(path, O_RDONLY);
        if (fd < 0) {
-               sr_err("Error opening %s: %s", path, strerror(errno));
+               sr_err("Error opening %s: %s", path, g_strerror(errno));
                ch->enabled = FALSE;
                return SR_ERR;
        }
index 14b5decf2473859d5ef0cc5a44734abf33d77879..b1cbac096b5533f4031950ffd62a7005043b12d6 100644 (file)
@@ -49,7 +49,7 @@ int dslogic_fpga_firmware_upload(const struct sr_dev_inst *sdi,
 
        usb = sdi->conn;
        if (stat(filename, &st) < 0) {
-               sr_err("Unable to upload FPGA firmware: %s", strerror(errno));
+               sr_err("Unable to upload FPGA firmware: %s", g_strerror(errno));
                return SR_ERR;
        }
 
@@ -64,7 +64,7 @@ int dslogic_fpga_firmware_upload(const struct sr_dev_inst *sdi,
        buf = g_malloc(FW_BUFSIZE);
 
        if (!(fw = g_fopen(filename, "rb"))) {
-               sr_err("Unable to open %s for reading: %s.", filename, strerror(errno));
+               sr_err("Unable to open %s for reading: %s.", filename, g_strerror(errno));
                return SR_ERR;
        }
 
index 6daa5d9ffe6087fe2b8edd525bfd3bc2bf4abf79..751d2d261a3df742033922916fbb68557571808b 100644 (file)
@@ -82,14 +82,14 @@ static void process_line(struct sr_dev_inst *sdi)
                case AQ_I2:
                        if (sr_atod(devc->buf, &dbl) != SR_OK) {
                                sr_err("Failed to convert '%s' to double, errno=%d %s",
-                                       devc->buf, errno, strerror(errno));
+                                       devc->buf, errno, g_strerror(errno));
                                dbl = 0.0;
                        }
                        break;
                case AQ_STATUS:
                        if (sr_atoi(devc->buf, &auxint) != SR_OK) {
                                sr_err("Failed to convert '%s' to int, errno=%d %s",
-                                       devc->buf, errno, strerror(errno));
+                                       devc->buf, errno, g_strerror(errno));
                                auxint = 0;
                        }
                        break;
index 532320d9216a10f132652e0d8b5c36a9d4c7bfba..5e43c3bd45903014d8175be0c49b665c9b4b1f4a 100644 (file)
@@ -491,7 +491,7 @@ static int upload_fpga_bitstream(const struct sr_dev_inst *sdi,
                sr_info("Uploading FPGA bitstream at %s.", filename);
                if (!(fw = g_fopen(filename, "rb"))) {
                        sr_err("Unable to open bitstream file %s for reading: %s.",
-                              filename, strerror(errno));
+                              filename, g_strerror(errno));
                        return SR_ERR;
                }
 
index 8e51e3f96b7285d23611d77b8ac8d46083ce1593..71604658809761444892d92cf625df2591408006 100644 (file)
@@ -431,7 +431,7 @@ SR_API int sr_input_scan_file(const char *filename, const struct sr_input **in)
        }
 
        if (stat(filename, &st) < 0) {
-               sr_err("%s", strerror(errno));
+               sr_err("%s", g_strerror(errno));
                return SR_ERR_ARG;
        }
 
@@ -471,7 +471,7 @@ SR_API int sr_input_scan_file(const char *filename, const struct sr_input **in)
                                                GINT_TO_POINTER(st.st_size));
                        } else if (mitem == SR_INPUT_META_HEADER) {
                                if ((fd = open(filename, O_RDONLY)) < 0) {
-                                       sr_err("%s", strerror(errno));
+                                       sr_err("%s", g_strerror(errno));
                                        return SR_ERR;
                                }
                                size = read(fd, header_buf->str, 128);
@@ -479,7 +479,7 @@ SR_API int sr_input_scan_file(const char *filename, const struct sr_input **in)
                                close(fd);
                                if (size <= 0) {
                                        g_string_free(header_buf, TRUE);
-                                       sr_err("%s", strerror(errno));
+                                       sr_err("%s", g_strerror(errno));
                                        return SR_ERR;
                                }
                                g_hash_table_insert(meta, GINT_TO_POINTER(mitem), header_buf);
index e52fec875fbc9031e384622c29e683fd78eb86ec..476ed57a2083cd178d3bc6800b10cbb7775858a1 100644 (file)
@@ -186,7 +186,7 @@ static int zip_append(const struct sr_output *o, unsigned char *buf,
                if ((tmpfile = g_mkstemp(tmpname)) == -1)
                        return SR_ERR;
                if (write(tmpfile, metafile, len) < 0) {
-                       sr_dbg("Failed to create new metadata: %s", strerror(errno));
+                       sr_dbg("Failed to create new metadata: %s", g_strerror(errno));
                        g_free(metafile);
                        unlink(tmpname);
                        return SR_ERR;
index b598d70d0488c354d056be2ad6c34050ef4dbee7..cf01c905cf65f8bfa4745275bbe820e15bbb0edc 100644 (file)
@@ -107,7 +107,7 @@ static int scpi_tcp_open(void *priv)
 
        if (tcp->socket < 0) {
                sr_err("Failed to connect to %s:%s: %s", tcp->address, tcp->port,
-                               strerror(errno));
+                               g_strerror(errno));
                return SR_ERR;
        }
 
@@ -142,7 +142,7 @@ static int scpi_tcp_send(void *priv, const char *command)
        g_free(terminated_command);
 
        if (out < 0) {
-               sr_err("Send error: %s", strerror(errno));
+               sr_err("Send error: %s", g_strerror(errno));
                return SR_ERR;
        }
 
@@ -174,7 +174,7 @@ static int scpi_tcp_raw_read_data(void *priv, char *buf, int maxlen)
        len = recv(tcp->socket, buf, maxlen, 0);
 
        if (len < 0) {
-               sr_err("Receive error: %s", strerror(errno));
+               sr_err("Receive error: %s", g_strerror(errno));
                return SR_ERR;
        }
 
@@ -194,7 +194,7 @@ static int scpi_tcp_rigol_read_data(void *priv, char *buf, int maxlen)
                len = recv(tcp->socket, tcp->length_buf + tcp->length_bytes_read,
                                LENGTH_BYTES - tcp->length_bytes_read, 0);
                if (len < 0) {
-                       sr_err("Receive error: %s", strerror(errno));
+                       sr_err("Receive error: %s", g_strerror(errno));
                        return SR_ERR;
                }
 
@@ -212,7 +212,7 @@ static int scpi_tcp_rigol_read_data(void *priv, char *buf, int maxlen)
        len = recv(tcp->socket, buf, maxlen, 0);
 
        if (len < 0) {
-               sr_err("Receive error: %s", strerror(errno));
+               sr_err("Receive error: %s", g_strerror(errno));
                return SR_ERR;
        }
 
index 5aed89b8bbf2530cccfc21c0d1d3cba1ff9ed616..b497aad87ac92e04e0a254eb0352a209b0614bb7 100644 (file)
@@ -62,7 +62,7 @@ SR_PRIV int sr_sessionfile_check(const char *filename)
                return SR_ERR_ARG;
 
        if (stat(filename, &st) == -1) {
-               sr_err("Couldn't stat %s: %s", filename, strerror(errno));
+               sr_err("Couldn't stat %s: %s", filename, g_strerror(errno));
                return SR_ERR;
        }
 
@@ -464,7 +464,7 @@ SR_API int sr_session_append(struct sr_session *session, const char *filename,
                if ((tmpfile = g_mkstemp(tmpname)) == -1)
                        return SR_ERR;
                if (write(tmpfile, metafile, len) < 0) {
-                       sr_dbg("Failed to create new metadata: %s", strerror(errno));
+                       sr_dbg("Failed to create new metadata: %s", g_strerror(errno));
                        g_free(metafile);
                        unlink(tmpname);
                        return SR_ERR;