portability: Use g_strerror() in favor of strerror().

This commit is contained in:
Uwe Hermann 2015-09-09 09:16:58 +02:00
parent 34577da641
commit 7237e91262
10 changed files with 24 additions and 24 deletions

View 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;
}

View 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;
}

View 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;
}

View 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;
}

View 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;

View 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;
}

View 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);

View 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;

View 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;
}

View 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;