From: Uwe Hermann Date: Wed, 9 Sep 2015 07:16:58 +0000 (+0200) Subject: portability: Use g_strerror() in favor of strerror(). X-Git-Tag: libsigrok-0.4.0~319 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=7237e91262251a138cf150f9fcfe7b05d0e5904b;p=libsigrok.git portability: Use g_strerror() in favor of strerror(). --- diff --git a/src/ezusb.c b/src/ezusb.c index 465dab03..601c818b 100644 --- a/src/ezusb.c +++ b/src/ezusb.c @@ -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; } diff --git a/src/hardware/baylibre-acme/gpio.c b/src/hardware/baylibre-acme/gpio.c index bb6c54d5..c2e6da9d 100644 --- a/src/hardware/baylibre-acme/gpio.c +++ b/src/hardware/baylibre-acme/gpio.c @@ -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; } diff --git a/src/hardware/baylibre-acme/protocol.c b/src/hardware/baylibre-acme/protocol.c index 8e730f15..a50c2219 100644 --- a/src/hardware/baylibre-acme/protocol.c +++ b/src/hardware/baylibre-acme/protocol.c @@ -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; } diff --git a/src/hardware/fx2lafw/dslogic.c b/src/hardware/fx2lafw/dslogic.c index 14b5decf..b1cbac09 100644 --- a/src/hardware/fx2lafw/dslogic.c +++ b/src/hardware/fx2lafw/dslogic.c @@ -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; } diff --git a/src/hardware/motech-lps-30x/protocol.c b/src/hardware/motech-lps-30x/protocol.c index 6daa5d9f..751d2d26 100644 --- a/src/hardware/motech-lps-30x/protocol.c +++ b/src/hardware/motech-lps-30x/protocol.c @@ -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; diff --git a/src/hardware/saleae-logic16/protocol.c b/src/hardware/saleae-logic16/protocol.c index 532320d9..5e43c3bd 100644 --- a/src/hardware/saleae-logic16/protocol.c +++ b/src/hardware/saleae-logic16/protocol.c @@ -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; } diff --git a/src/input/input.c b/src/input/input.c index 8e51e3f9..71604658 100644 --- a/src/input/input.c +++ b/src/input/input.c @@ -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); diff --git a/src/output/srzip.c b/src/output/srzip.c index e52fec87..476ed57a 100644 --- a/src/output/srzip.c +++ b/src/output/srzip.c @@ -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; diff --git a/src/scpi/scpi_tcp.c b/src/scpi/scpi_tcp.c index b598d70d..cf01c905 100644 --- a/src/scpi/scpi_tcp.c +++ b/src/scpi/scpi_tcp.c @@ -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; } diff --git a/src/session_file.c b/src/session_file.c index 5aed89b8..b497aad8 100644 --- a/src/session_file.c +++ b/src/session_file.c @@ -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;