From: Soeren Apel Date: Fri, 29 Jan 2016 22:13:32 +0000 (+0100) Subject: hameg-hmo/yokogawa-dlm: Fix warning about pointer typecast X-Git-Tag: libsigrok-0.4.0~3 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=10c4ca9c5bd9b2e917759e9fddc6f8655895b92c;p=libsigrok.git hameg-hmo/yokogawa-dlm: Fix warning about pointer typecast --- diff --git a/src/hardware/hameg-hmo/protocol.c b/src/hardware/hameg-hmo/protocol.c index 60731ec4..de93e74a 100644 --- a/src/hardware/hameg-hmo/protocol.c +++ b/src/hardware/hameg-hmo/protocol.c @@ -355,7 +355,8 @@ static int scope_state_get_array_option(struct sr_scpi_dev_inst *scpi, static int array_float_get(gchar *value, const uint64_t array[][2], int array_len, unsigned int *result) { - int i, pos, e; + int i, e; + size_t pos; uint64_t f; float s; unsigned int s_int; @@ -365,8 +366,7 @@ static int array_float_get(gchar *value, const uint64_t array[][2], memset(es, 0, sizeof(es)); /* Get index of the separating 'E' character and break up the string. */ - pos = (int)g_strstr_len(value, strlen(value), "E"); - pos -= (int)value; + pos = strcspn(value, "E"); strncpy(ss, value, pos); strncpy(es, &(value[pos+1]), 3); diff --git a/src/hardware/yokogawa-dlm/protocol.c b/src/hardware/yokogawa-dlm/protocol.c index 185f9d5c..e63e6357 100644 --- a/src/hardware/yokogawa-dlm/protocol.c +++ b/src/hardware/yokogawa-dlm/protocol.c @@ -372,7 +372,8 @@ static int array_option_get(char *value, const char *(*array)[], static int array_float_get(gchar *value, const uint64_t array[][2], int array_len, int *result) { - int i, pos, e; + int i, e; + size_t pos; uint64_t f; float s; unsigned int s_int; @@ -382,8 +383,7 @@ static int array_float_get(gchar *value, const uint64_t array[][2], memset(es, 0, sizeof(es)); /* Get index of the separating 'E' character and break up the string. */ - pos = (int)g_strstr_len(value, strlen(value), "E"); - pos -= (int)value; + pos = strcspn(value, "E"); strncpy(ss, value, pos); strncpy(es, &(value[pos+1]), 3);