Cleanup: pass NULL pointer for error string pointer

Since we never did anything with the error string, why even ask for it.
And this way we don't have to deal with the memory returned, either.

Found by Coverity. Fixes CIDs 350124, 350113, 350106, 350099, 350091

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2019-10-26 17:11:44 -04:00
parent cc2269b9c5
commit d3d51b175d
3 changed files with 22 additions and 30 deletions

View file

@ -274,7 +274,6 @@ static int divinglog_dive(void *param, int columns, char **data, char **column)
int retval = 0, diveid;
struct parser_state *state = (struct parser_state *)param;
sqlite3 *handle = state->sql_handle;
char *err = NULL;
char get_profile_template[] = "select ProfileInt,Profile,Profile2,Profile3,Profile4,Profile5 from Logbook where ID = %d";
char get_cylinder0_template[] = "select 0,TankSize,PresS,PresE,PresW,O2,He,DblTank from Logbook where ID = %d";
char get_cylinder_template[] = "select TankID,TankSize,PresS,PresE,PresW,O2,He,DblTank from Tank where LogID = %d order by TankID";
@ -347,14 +346,14 @@ static int divinglog_dive(void *param, int columns, char **data, char **column)
}
snprintf(get_buffer, sizeof(get_buffer) - 1, get_cylinder0_template, diveid);
retval = sqlite3_exec(handle, get_buffer, &divinglog_cylinder, state, &err);
retval = sqlite3_exec(handle, get_buffer, &divinglog_cylinder, state, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "%s", "Database query divinglog_cylinder0 failed.\n");
return 1;
}
snprintf(get_buffer, sizeof(get_buffer) - 1, get_cylinder_template, diveid);
retval = sqlite3_exec(handle, get_buffer, &divinglog_cylinder, state, &err);
retval = sqlite3_exec(handle, get_buffer, &divinglog_cylinder, state, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "%s", "Database query divinglog_cylinder failed.\n");
return 1;
@ -384,7 +383,7 @@ static int divinglog_dive(void *param, int columns, char **data, char **column)
}
snprintf(get_buffer, sizeof(get_buffer) - 1, get_profile_template, diveid);
retval = sqlite3_exec(handle, get_buffer, &divinglog_profile, state, &err);
retval = sqlite3_exec(handle, get_buffer, &divinglog_profile, state, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "%s", "Database query divinglog_profile failed.\n");
return 1;
@ -403,7 +402,6 @@ int parse_divinglog_buffer(sqlite3 *handle, const char *url, const char *buffer,
UNUSED(size);
int retval;
char *err = NULL;
struct parser_state state;
init_parser_state(&state);
@ -414,7 +412,7 @@ int parse_divinglog_buffer(sqlite3 *handle, const char *url, const char *buffer,
char get_dives[] = "select Number,strftime('%s',Divedate || ' ' || ifnull(Entrytime,'00:00')),Country || ' - ' || City || ' - ' || Place,Buddy,Comments,Depth,Divetime,Divemaster,Airtemp,Watertemp,Weight,Divesuit,Computer,ID,Visibility,SupplyType from Logbook where UUID not in (select UUID from DeletedRecords)";
retval = sqlite3_exec(handle, get_dives, &divinglog_dive, &state, &err);
retval = sqlite3_exec(handle, get_dives, &divinglog_dive, &state, NULL);
free_parser_state(&state);
if (retval != SQLITE_OK) {

View file

@ -201,7 +201,6 @@ static int shearwater_dive(void *param, int columns, char **data, char **column)
int retval = 0;
struct parser_state *state = (struct parser_state *)param;
sqlite3 *handle = state->sql_handle;
char *err = NULL;
char get_profile_template[] = "select currentTime,currentDepth,waterTemp,averagePPO2,currentNdl,CNSPercent,decoCeiling,firstStopDepth,firstStopTime from dive_log_records where diveLogId=%ld";
char get_profile_template_ai[] = "select currentTime,currentDepth,waterTemp,averagePPO2,currentNdl,CNSPercent,decoCeiling,aiSensor0_PressurePSI,aiSensor1_PressurePSI,firstStopDepth,firstStopTime from dive_log_records where diveLogId = %ld";
char get_cylinder_template[] = "select fractionO2,fractionHe from dive_log_records where diveLogId = %ld group by fractionO2,fractionHe";
@ -276,7 +275,7 @@ static int shearwater_dive(void *param, int columns, char **data, char **column)
if (data[11]) {
snprintf(get_buffer, sizeof(get_buffer) - 1, get_mode_template, dive_id);
retval = sqlite3_exec(handle, get_buffer, &shearwater_mode, state, &err);
retval = sqlite3_exec(handle, get_buffer, &shearwater_mode, state, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "%s", "Database query shearwater_mode failed.\n");
return 1;
@ -284,24 +283,24 @@ static int shearwater_dive(void *param, int columns, char **data, char **column)
}
snprintf(get_buffer, sizeof(get_buffer) - 1, get_cylinder_template, dive_id);
retval = sqlite3_exec(handle, get_buffer, &shearwater_cylinders, state, &err);
retval = sqlite3_exec(handle, get_buffer, &shearwater_cylinders, state, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "%s", "Database query shearwater_cylinders failed.\n");
return 1;
}
snprintf(get_buffer, sizeof(get_buffer) - 1, get_changes_template, dive_id);
retval = sqlite3_exec(handle, get_buffer, &shearwater_changes, state, &err);
retval = sqlite3_exec(handle, get_buffer, &shearwater_changes, state, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "%s", "Database query shearwater_changes failed.\n");
return 1;
}
snprintf(get_buffer, sizeof(get_buffer) - 1, get_profile_template_ai, dive_id);
retval = sqlite3_exec(handle, get_buffer, &shearwater_ai_profile_sample, state, &err);
retval = sqlite3_exec(handle, get_buffer, &shearwater_ai_profile_sample, state, NULL);
if (retval != SQLITE_OK) {
snprintf(get_buffer, sizeof(get_buffer) - 1, get_profile_template, dive_id);
retval = sqlite3_exec(handle, get_buffer, &shearwater_profile_sample, state, &err);
retval = sqlite3_exec(handle, get_buffer, &shearwater_profile_sample, state, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "%s", "Database query shearwater_profile_sample failed.\n");
return 1;
@ -321,7 +320,6 @@ static int shearwater_cloud_dive(void *param, int columns, char **data, char **c
int retval = 0;
struct parser_state *state = (struct parser_state *)param;
sqlite3 *handle = state->sql_handle;
char *err = NULL;
char get_profile_template[] = "select currentTime,currentDepth,waterTemp,averagePPO2,currentNdl,CNSPercent,decoCeiling,firstStopDepth,firstStopTime from dive_log_records where diveLogId=%ld";
char get_profile_template_ai[] = "select currentTime,currentDepth,waterTemp,averagePPO2,currentNdl,CNSPercent,decoCeiling,aiSensor0_PressurePSI,aiSensor1_PressurePSI,firstStopDepth,firstStopTime from dive_log_records where diveLogId = %ld";
char get_cylinder_template[] = "select fractionO2 / 100,fractionHe / 100 from dive_log_records where diveLogId = %ld group by fractionO2,fractionHe";
@ -400,7 +398,7 @@ static int shearwater_cloud_dive(void *param, int columns, char **data, char **c
if (data[11]) {
snprintf(get_buffer, sizeof(get_buffer) - 1, get_mode_template, dive_id);
retval = sqlite3_exec(handle, get_buffer, &shearwater_mode, state, &err);
retval = sqlite3_exec(handle, get_buffer, &shearwater_mode, state, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "%s", "Database query shearwater_mode failed.\n");
return 1;
@ -408,24 +406,24 @@ static int shearwater_cloud_dive(void *param, int columns, char **data, char **c
}
snprintf(get_buffer, sizeof(get_buffer) - 1, get_cylinder_template, dive_id);
retval = sqlite3_exec(handle, get_buffer, &shearwater_cylinders, state, &err);
retval = sqlite3_exec(handle, get_buffer, &shearwater_cylinders, state, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "%s", "Database query shearwater_cylinders failed.\n");
return 1;
}
snprintf(get_buffer, sizeof(get_buffer) - 1, get_changes_template, dive_id);
retval = sqlite3_exec(handle, get_buffer, &shearwater_changes, state, &err);
retval = sqlite3_exec(handle, get_buffer, &shearwater_changes, state, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "%s", "Database query shearwater_changes failed.\n");
return 1;
}
snprintf(get_buffer, sizeof(get_buffer) - 1, get_profile_template_ai, dive_id);
retval = sqlite3_exec(handle, get_buffer, &shearwater_ai_profile_sample, state, &err);
retval = sqlite3_exec(handle, get_buffer, &shearwater_ai_profile_sample, state, NULL);
if (retval != SQLITE_OK) {
snprintf(get_buffer, sizeof(get_buffer) - 1, get_profile_template, dive_id);
retval = sqlite3_exec(handle, get_buffer, &shearwater_profile_sample, state, &err);
retval = sqlite3_exec(handle, get_buffer, &shearwater_profile_sample, state, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "%s", "Database query shearwater_profile_sample failed.\n");
return 1;
@ -444,7 +442,6 @@ int parse_shearwater_buffer(sqlite3 *handle, const char *url, const char *buffer
UNUSED(size);
int retval;
char *err = NULL;
struct parser_state state;
init_parser_state(&state);
@ -458,7 +455,7 @@ int parse_shearwater_buffer(sqlite3 *handle, const char *url, const char *buffer
char get_dives[] = "select l.number,timestamp,location||' / '||site,buddy,notes,imperialUnits,maxDepth,maxTime,startSurfacePressure,computerSerial,computerModel,i.diveId FROM dive_info AS i JOIN dive_logs AS l ON i.diveId=l.diveId";
retval = sqlite3_exec(handle, get_dives, &shearwater_dive, &state, &err);
retval = sqlite3_exec(handle, get_dives, &shearwater_dive, &state, NULL);
free_parser_state(&state);
if (retval != SQLITE_OK) {
@ -476,7 +473,6 @@ int parse_shearwater_cloud_buffer(sqlite3 *handle, const char *url, const char *
UNUSED(size);
int retval;
char *err = NULL;
struct parser_state state;
init_parser_state(&state);
@ -487,7 +483,7 @@ int parse_shearwater_cloud_buffer(sqlite3 *handle, const char *url, const char *
char get_dives[] = "select l.number,strftime('%s', DiveDate),location||' / '||site,buddy,notes,imperialUnits,maxDepth,maxTime,startSurfacePressure,computerSerial,computerModel,d.diveId,l.sampleRateMs FROM dive_details AS d JOIN dive_logs AS l ON d.diveId=l.diveId";
retval = sqlite3_exec(handle, get_dives, &shearwater_cloud_dive, &state, &err);
retval = sqlite3_exec(handle, get_dives, &shearwater_cloud_dive, &state, NULL);
free_parser_state(&state);
if (retval != SQLITE_OK) {

View file

@ -170,7 +170,6 @@ static int dm4_dive(void *param, int columns, char **data, char **column)
float *profileBlob;
unsigned char *tempBlob;
int *pressureBlob;
char *err = NULL;
char get_events_template[] = "select * from Mark where DiveId = %d";
char get_tags_template[] = "select Text from DiveTag where DiveId = %d";
char get_events[64];
@ -260,14 +259,14 @@ static int dm4_dive(void *param, int columns, char **data, char **column)
}
snprintf(get_events, sizeof(get_events) - 1, get_events_template, state->cur_dive->number);
retval = sqlite3_exec(handle, get_events, &dm4_events, state, &err);
retval = sqlite3_exec(handle, get_events, &dm4_events, state, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "%s", "Database query dm4_events failed.\n");
return 1;
}
snprintf(get_events, sizeof(get_events) - 1, get_tags_template, state->cur_dive->number);
retval = sqlite3_exec(handle, get_events, &dm4_tags, state, &err);
retval = sqlite3_exec(handle, get_events, &dm4_tags, state, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "%s", "Database query dm4_tags failed.\n");
return 1;
@ -380,7 +379,6 @@ static int dm5_dive(void *param, int columns, char **data, char **column)
struct parser_state *state = (struct parser_state *)param;
sqlite3 *handle = state->sql_handle;
unsigned const char *sampleBlob;
char *err = NULL;
char get_events_template[] = "select * from Mark where DiveId = %d";
char get_tags_template[] = "select Text from DiveTag where DiveId = %d";
char get_cylinders_template[] = "select * from DiveMixture where DiveId = %d";
@ -428,7 +426,7 @@ static int dm5_dive(void *param, int columns, char **data, char **column)
utf8_string(data[5], &state->cur_dive->dc.model);
snprintf(get_events, sizeof(get_events) - 1, get_cylinders_template, state->cur_dive->number);
retval = sqlite3_exec(handle, get_events, &dm5_cylinders, state, &err);
retval = sqlite3_exec(handle, get_events, &dm5_cylinders, state, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "%s", "Database query dm5_cylinders failed.\n");
return 1;
@ -534,21 +532,21 @@ static int dm5_dive(void *param, int columns, char **data, char **column)
}
snprintf(get_events, sizeof(get_events) - 1, get_gaschange_template, state->cur_dive->number);
retval = sqlite3_exec(handle, get_events, &dm5_gaschange, state, &err);
retval = sqlite3_exec(handle, get_events, &dm5_gaschange, state, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "%s", "Database query dm5_gaschange failed.\n");
return 1;
}
snprintf(get_events, sizeof(get_events) - 1, get_events_template, state->cur_dive->number);
retval = sqlite3_exec(handle, get_events, &dm4_events, state, &err);
retval = sqlite3_exec(handle, get_events, &dm4_events, state, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "%s", "Database query dm4_events failed.\n");
return 1;
}
snprintf(get_events, sizeof(get_events) - 1, get_tags_template, state->cur_dive->number);
retval = sqlite3_exec(handle, get_events, &dm4_tags, state, &err);
retval = sqlite3_exec(handle, get_events, &dm4_tags, state, NULL);
if (retval != SQLITE_OK) {
fprintf(stderr, "%s", "Database query dm4_tags failed.\n");
return 1;