refactor: clean up some compiler warnings (#152)

This commit is contained in:
Carlos Gomes Martinho 2020-03-21 10:50:33 +01:00 committed by GitHub
parent 62ac3678ff
commit 6edab86078
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 10 deletions

View File

@ -785,8 +785,6 @@ mbus_register_found_event(mbus_handle * handle, void (*event)(mbus_handle * hand
int mbus_fixed_normalize(int medium_unit, long medium_value, char **unit_out, double *value_out, char **quantity_out) int mbus_fixed_normalize(int medium_unit, long medium_value, char **unit_out, double *value_out, char **quantity_out)
{ {
double exponent = 0.0;
int i;
medium_unit = medium_unit & 0x3F; medium_unit = medium_unit & 0x3F;
if (unit_out == NULL || value_out == NULL || quantity_out == NULL) if (unit_out == NULL || value_out == NULL || quantity_out == NULL)
@ -807,7 +805,7 @@ int mbus_fixed_normalize(int medium_unit, long medium_value, char **unit_out, do
break; break;
default: default:
for(i=0; fixed_table[i].vif < 0xfff; ++i) for(int i=0; fixed_table[i].vif < 0xfff; ++i)
{ {
if (fixed_table[i].vif == medium_unit) if (fixed_table[i].vif == medium_unit)
{ {
@ -820,7 +818,6 @@ int mbus_fixed_normalize(int medium_unit, long medium_value, char **unit_out, do
*unit_out = strdup("Unknown"); *unit_out = strdup("Unknown");
*quantity_out = strdup("Unknown"); *quantity_out = strdup("Unknown");
exponent = 0.0;
*value_out = 0.0; *value_out = 0.0;
return -1; return -1;
} }
@ -835,7 +832,6 @@ int mbus_variable_value_decode(mbus_data_record *record, double *value_out_real,
unsigned char vif, vife; unsigned char vif, vife;
struct tm time; struct tm time;
int value_out_int; int value_out_int;
long value_out_long;
long long value_out_long_long; long long value_out_long_long;
*value_out_real = 0.0; *value_out_real = 0.0;
*value_out_str = NULL; *value_out_str = NULL;
@ -1038,7 +1034,6 @@ int
mbus_vif_unit_normalize(int vif, double value, char **unit_out, double *value_out, char **quantity_out) mbus_vif_unit_normalize(int vif, double value, char **unit_out, double *value_out, char **quantity_out)
{ {
int i; int i;
double exponent = 1.0;
unsigned newVif = vif & 0xF7F; /* clear extension bit */ unsigned newVif = vif & 0xF7F; /* clear extension bit */
MBUS_DEBUG("vif_unit_normalize = 0x%03X \n", vif); MBUS_DEBUG("vif_unit_normalize = 0x%03X \n", vif);
@ -1063,7 +1058,6 @@ mbus_vif_unit_normalize(int vif, double value, char **unit_out, double *value_ou
MBUS_ERROR("%s: Unknown VIF 0x%03X\n", __PRETTY_FUNCTION__, newVif); MBUS_ERROR("%s: Unknown VIF 0x%03X\n", __PRETTY_FUNCTION__, newVif);
*unit_out = strdup("Unknown (VIF=0x%.02X)"); *unit_out = strdup("Unknown (VIF=0x%.02X)");
*quantity_out = strdup("Unknown"); *quantity_out = strdup("Unknown");
exponent = 0.0;
*value_out = 0.0; *value_out = 0.0;
return -1; return -1;
} }

View File

@ -18,7 +18,7 @@ int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
FILE *fp = NULL; FILE *fp = NULL;
size_t buff_len, len; size_t len;
int normalized = 0; int normalized = 0;
unsigned char buf[1024]; unsigned char buf[1024];
mbus_frame reply; mbus_frame reply;
@ -53,6 +53,7 @@ main(int argc, char *argv[])
if (ferror(fp) != 0) if (ferror(fp) != 0)
{ {
fprintf(stderr, "%s: failed to read '%s'\n", argv[0], file); fprintf(stderr, "%s: failed to read '%s'\n", argv[0], file);
fclose(fp);
return 1; return 1;
} }

View File

@ -18,7 +18,7 @@ int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
FILE *fp = NULL; FILE *fp = NULL;
size_t buff_len, len; size_t buff_len;
int result, normalized = 0; int result, normalized = 0;
unsigned char raw_buff[4096], buff[4096]; unsigned char raw_buff[4096], buff[4096];
mbus_frame reply; mbus_frame reply;
@ -48,11 +48,12 @@ main(int argc, char *argv[])
} }
memset(raw_buff, 0, sizeof(raw_buff)); memset(raw_buff, 0, sizeof(raw_buff));
len = fread(raw_buff, 1, sizeof(raw_buff), fp); fread(raw_buff, 1, sizeof(raw_buff), fp);
if (ferror(fp) != 0) if (ferror(fp) != 0)
{ {
fprintf(stderr, "%s: failed to read '%s'\n", argv[0], file); fprintf(stderr, "%s: failed to read '%s'\n", argv[0], file);
fclose(fp);
return 1; return 1;
} }