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:
parent
6c7d80afca
commit
8d5228015d
|
@ -22,7 +22,6 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
|
||||||
#include "libsigrok.h"
|
#include "libsigrok.h"
|
||||||
#include "libsigrok-internal.h"
|
#include "libsigrok-internal.h"
|
||||||
#include "agilent-dmm.h"
|
#include "agilent-dmm.h"
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "libsigrok.h"
|
#include "libsigrok.h"
|
||||||
#include "libsigrok-internal.h"
|
#include "libsigrok-internal.h"
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
|
||||||
#include "protocol.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);
|
memset(packet, 0, PACKET_SIZE);
|
||||||
if ((ret = serial_read_nonblocking(serial, packet, PACKET_SIZE)) < 0) {
|
if ((ret = serial_read_nonblocking(serial, packet, PACKET_SIZE)) < 0) {
|
||||||
sr_err("Unable to read while probing for hardware: %s",
|
sr_err("Unable to read while probing for hardware: %s",
|
||||||
strerror(errno));
|
sr_strerror(ret));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (ret != PACKET_SIZE || packet[0] != 0xaa || packet[1] != 0xaa) {
|
if (ret != PACKET_SIZE || packet[0] != 0xaa || packet[1] != 0xaa) {
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
|
||||||
#include "protocol.h"
|
#include "protocol.h"
|
||||||
|
|
||||||
static void dump_packet(char *msg, uint8_t *packet)
|
static void dump_packet(char *msg, uint8_t *packet)
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <errno.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "libsigrok.h"
|
#include "libsigrok.h"
|
||||||
#include "libsigrok-internal.h"
|
#include "libsigrok-internal.h"
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <errno.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "libsigrok.h"
|
#include "libsigrok.h"
|
||||||
#include "libsigrok-internal.h"
|
#include "libsigrok-internal.h"
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
#define LIBSIGROK_HARDWARE_CONRAD_DIGI_35_CPU_PROTOCOL_H
|
#define LIBSIGROK_HARDWARE_CONRAD_DIGI_35_CPU_PROTOCOL_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <errno.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include "libsigrok.h"
|
#include "libsigrok.h"
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
|
||||||
#include "libsigrok.h"
|
#include "libsigrok.h"
|
||||||
#include "libsigrok-internal.h"
|
#include "libsigrok-internal.h"
|
||||||
#include "fluke-dmm.h"
|
#include "fluke-dmm.h"
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include "libsigrok.h"
|
#include "libsigrok.h"
|
||||||
#include "libsigrok-internal.h"
|
#include "libsigrok-internal.h"
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "protocol.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)
|
SR_PRIV int lps_query_status(struct sr_dev_inst* sdi)
|
||||||
{
|
{
|
||||||
char buf[LINELEN_MAX];
|
char buf[LINELEN_MAX];
|
||||||
int stat;
|
int stat, ret;
|
||||||
struct dev_context* devc;
|
struct dev_context* devc;
|
||||||
|
|
||||||
devc = (struct dev_context*)sdi->priv;
|
devc = (struct dev_context*)sdi->priv;
|
||||||
|
|
||||||
devc->req_sent_at = g_get_real_time();
|
devc->req_sent_at = g_get_real_time();
|
||||||
|
|
||||||
if (lps_cmd_reply(buf, sdi->conn, "STATUS") < 0) {
|
if ((ret = lps_cmd_reply(buf, sdi->conn, "STATUS")) < 0) {
|
||||||
sr_err("%s: Failed to read status: %d %s", __func__, errno, strerror(errno));
|
sr_err("%s: Failed to read status: %s.", __func__,
|
||||||
|
sr_strerror(ret));
|
||||||
return SR_ERR;
|
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;
|
struct sr_channel_group *cg;
|
||||||
GSList *devices;
|
GSList *devices;
|
||||||
const char *conn, *serialcomm;
|
const char *conn, *serialcomm;
|
||||||
int cnt;
|
int cnt, ret;
|
||||||
gchar buf[LINELEN_MAX];
|
gchar buf[LINELEN_MAX];
|
||||||
gchar channel[10];
|
gchar channel[10];
|
||||||
char *verstr;
|
char *verstr;
|
||||||
|
@ -434,7 +434,7 @@ static GSList *do_scan(lps_modelid modelid, struct sr_dev_driver *drv, GSList *o
|
||||||
|
|
||||||
/* Query version */
|
/* Query version */
|
||||||
verstr = NULL;
|
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)) {
|
if (strncmp(buf, "Ver-", 4)) {
|
||||||
sr_spew("Version string %s not recognized.", buf);
|
sr_spew("Version string %s not recognized.", buf);
|
||||||
goto exit_err;
|
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.
|
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. */
|
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 = g_malloc0(sizeof(struct sr_dev_inst));
|
||||||
sdi->status = SR_ST_INACTIVE;
|
sdi->status = SR_ST_INACTIVE;
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include "libsigrok.h"
|
#include "libsigrok.h"
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include "libsigrok.h"
|
#include "libsigrok.h"
|
||||||
#include "libsigrok-internal.h"
|
#include "libsigrok-internal.h"
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include "libsigrok.h"
|
#include "libsigrok.h"
|
||||||
#include "libsigrok-internal.h"
|
#include "libsigrok-internal.h"
|
||||||
|
|
Loading…
Reference in New Issue