Various errno/strerror() related fixes.

- Don't #include <errno.h> in files that don't actually need it.

 - Don't use strerror() on error codes from functions that don't set
   errno. Replace strerror() with sr_strerror() for libsigrok functions.
This commit is contained in:
Uwe Hermann 2015-07-29 19:31:43 +02:00
parent 6c7d80afca
commit 8d5228015d
14 changed files with 9 additions and 21 deletions

View File

@ -22,7 +22,6 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include "libsigrok.h"
#include "libsigrok-internal.h"
#include "agilent-dmm.h"

View File

@ -20,7 +20,6 @@
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <math.h>
#include "libsigrok.h"
#include "libsigrok-internal.h"

View File

@ -18,7 +18,6 @@
*/
#include <string.h>
#include <errno.h>
#include "protocol.h"
/*
@ -142,7 +141,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options, int modelid)
memset(packet, 0, PACKET_SIZE);
if ((ret = serial_read_nonblocking(serial, packet, PACKET_SIZE)) < 0) {
sr_err("Unable to read while probing for hardware: %s",
strerror(errno));
sr_strerror(ret));
return NULL;
}
if (ret != PACKET_SIZE || packet[0] != 0xaa || packet[1] != 0xaa) {

View File

@ -18,7 +18,6 @@
*/
#include <string.h>
#include <errno.h>
#include "protocol.h"
static void dump_packet(char *msg, uint8_t *packet)

View File

@ -17,7 +17,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

View File

@ -21,7 +21,6 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include "libsigrok.h"
#include "libsigrok-internal.h"

View File

@ -19,7 +19,6 @@
#include <stdlib.h>
#include <glib.h>
#include <errno.h>
#include <string.h>
#include "libsigrok.h"
#include "libsigrok-internal.h"

View File

@ -27,7 +27,6 @@
#define LIBSIGROK_HARDWARE_CONRAD_DIGI_35_CPU_PROTOCOL_H
#include <stdint.h>
#include <errno.h>
#include <string.h>
#include <glib.h>
#include "libsigrok.h"

View File

@ -22,7 +22,6 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include "libsigrok.h"
#include "libsigrok-internal.h"
#include "fluke-dmm.h"

View File

@ -20,7 +20,6 @@
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <errno.h>
#include <glib.h>
#include "libsigrok.h"
#include "libsigrok-internal.h"

View File

@ -24,7 +24,6 @@
*/
#include <ctype.h>
#include <errno.h>
#include <math.h>
#include <string.h>
#include "protocol.h"
@ -285,15 +284,16 @@ SR_PRIV int lps_process_status(struct sr_dev_inst* sdi, int stat)
SR_PRIV int lps_query_status(struct sr_dev_inst* sdi)
{
char buf[LINELEN_MAX];
int stat;
int stat, ret;
struct dev_context* devc;
devc = (struct dev_context*)sdi->priv;
devc->req_sent_at = g_get_real_time();
if (lps_cmd_reply(buf, sdi->conn, "STATUS") < 0) {
sr_err("%s: Failed to read status: %d %s", __func__, errno, strerror(errno));
if ((ret = lps_cmd_reply(buf, sdi->conn, "STATUS")) < 0) {
sr_err("%s: Failed to read status: %s.", __func__,
sr_strerror(ret));
return SR_ERR;
}
@ -379,7 +379,7 @@ static GSList *do_scan(lps_modelid modelid, struct sr_dev_driver *drv, GSList *o
struct sr_channel_group *cg;
GSList *devices;
const char *conn, *serialcomm;
int cnt;
int cnt, ret;
gchar buf[LINELEN_MAX];
gchar channel[10];
char *verstr;
@ -434,7 +434,7 @@ static GSList *do_scan(lps_modelid modelid, struct sr_dev_driver *drv, GSList *o
/* Query version */
verstr = NULL;
if (lps_cmd_reply(buf, serial, "VERSION") == SR_OK) {
if ((ret = lps_cmd_reply(buf, serial, "VERSION")) == SR_OK) {
if (strncmp(buf, "Ver-", 4)) {
sr_spew("Version string %s not recognized.", buf);
goto exit_err;
@ -445,7 +445,8 @@ static GSList *do_scan(lps_modelid modelid, struct sr_dev_driver *drv, GSList *o
}
else /* Bug in device FW 1.17: Querying version string fails while output is active.
Therefore just print an error message, but do not exit with error. */
sr_err("Failed to query for hardware version: %d %s", errno, strerror(errno));
sr_err("Failed to query for hardware version: %s.",
sr_strerror(ret));
sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->status = SR_ST_INACTIVE;

View File

@ -23,7 +23,6 @@
#include <stdint.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <math.h>
#include <glib.h>
#include "libsigrok.h"

View File

@ -23,7 +23,6 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <glib.h>
#include "libsigrok.h"
#include "libsigrok-internal.h"

View File

@ -21,7 +21,6 @@
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <errno.h>
#include <glib.h>
#include "libsigrok.h"
#include "libsigrok-internal.h"