Skip to content

Commit ac890ac

Browse files
authored
Small fixes (#503)
* Fix implicit function declaration * initialize errno * Fix possible memory leak
1 parent 5745935 commit ac890ac

8 files changed

Lines changed: 12 additions & 1 deletion

File tree

src/addmult.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ int init_and_load_multipliers(void) {
414414
return 0; // couldn't open file
415415
}
416416

417+
errno = 0;
417418
while ((read = getline(&s_inputbuffer, &s_inputbuffer_len, cfp)) != -1) {
418419
if (read > 0) {
419420
/* strip leading and trailing whitespace */

src/dxcc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ int load_ctydata(char *filename) {
355355
// set default for empty country == country nr 0
356356
dxcc_add("Not Specified : --: --: --: -00.00: 00.00: 0.0: :");
357357

358+
errno = 0;
358359
while ((read = getline(&buf, &buf_len, fd)) != -1) {
359360
if (read > 0) {
360361
g_strchomp(buf); /* drop CR and/or NL and */

src/initial_exchange.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ struct ie_list *make_ie_list(char *file) {
6868

6969
showstring("Using initial exchange file", file);
7070

71+
errno = 0;
7172
while ((read = getline(&inputbuffer, &inputbuffer_len, fp)) != -1) {
7273
if (read > 0) {
7374
linectr++;

src/parse_logcfg.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ int parse_configfile(FILE *fp) {
114114
size_t buffer_len;
115115
ssize_t read;
116116

117+
errno = 0;
117118
while ((read = getline(&buffer, &buffer_len, fp)) != -1) {
118119
if (read > 0) {
119120
g_strchug(buffer); // remove leading space
@@ -743,6 +744,7 @@ static int cfg_countrylist(const cfg_arg_t arg) {
743744
if ((fp = fopen(buffer, "r")) != NULL) {
744745
char *prefix = g_strdup_printf("%s:", whichcontest);
745746

747+
errno = 0;
746748
while ((read = getline(&buffer, &buffer_len, fp)) != -1) {
747749
if (read > 0) {
748750
g_strstrip(buffer); /* no leading/trailing whitespace*/
@@ -840,6 +842,8 @@ static int cfg_continentlist(const cfg_arg_t arg) {
840842

841843
if ((fp = fopen(buffer, "r")) != NULL) {
842844
char *prefix = g_strdup_printf("%s:", whichcontest);
845+
846+
errno = 0;
843847
while ((read = getline(&buffer, &buffer_len, fp)) != -1) {
844848
if (read > 0) {
845849
g_strstrip(buffer); /* no leading/trailing whitespace*/

src/readcabrillo.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,10 +474,12 @@ int readcabrillo(int mode) {
474474

475475
init_qso_array();
476476

477+
errno = 0;
477478
while ((read = getline(&logline, &read_len, fp1)) != -1) {
478479
if (read > 0) {
479480
cab_qso_to_tlf(logline, cabdesc);
480481
}
482+
errno = 0;
481483
}
482484
if (errno == ENOMEM) {
483485
fprintf(stderr, "Error in: %s:%d", __FILE__, __LINE__);

src/searchlog.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,7 @@ int load_callmaster(void) {
761761

762762
GHashTable *callset = g_hash_table_new(g_str_hash, g_str_equal);
763763

764+
errno = 0;
764765
while ((read = getline(&s_inputbuffer, &s_inputbuffer_len, cfp)) != -1) {
765766
if (read > 0) {
766767
g_strstrip(s_inputbuffer);

src/writecabrillo.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ struct linedata_t *get_next_qtc_record(FILE *fp, int qtcdirection) {
136136
}
137137

138138
if ((read = getline(&buffer, &buffer_len, fp)) == -1) {
139+
free(buffer);
139140
return NULL;
140141
}
141142

test/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ LIBS = @LIBM_LIB@ @PTHREAD_LIBS@ @GLIB_LIBS@ @HAMLIB_LIBS@ \
1616
noinst_HEADERS = \
1717
test.h
1818

19-
AM_CFLAGS += @PTHREAD_CFLAGS@
19+
AM_CFLAGS += @PTHREAD_CFLAGS@ -D_GNU_SOURCE
2020

2121
AM_CPPFLAGS += -DSRCDIR=\"$(abs_srcdir)\"
2222

0 commit comments

Comments
 (0)