From 32bff14871bf8f534fcdcdba1d8409430d6c464b Mon Sep 17 00:00:00 2001 From: David Phillips Date: Tue, 1 Sep 2015 21:19:01 +1200 Subject: Conforming to style, switching paramano-set to getopt (finally) --- common.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'common.c') diff --git a/common.c b/common.c index d1be19b..953a33b 100644 --- a/common.c +++ b/common.c @@ -30,7 +30,6 @@ int get_int_value_from_filef(const char* format, ...) va_start(a, format); value = vget_int_value_from_filef(format, a); va_end(a); - return value; } @@ -40,7 +39,6 @@ int get_int_value_from_filef(const char* format, ...) **********************************************************************/ int vget_int_value_from_filef(const char* format, va_list args) { - char filename[1024]; if (vsnprintf(filename, sizeof(filename), format, args) == sizeof(filename)) fprintf(stderr, "WARN: filename buffer too small"); @@ -53,9 +51,9 @@ int vget_int_value_from_filef(const char* format, va_list args) **********************************************************************/ int get_int_value_from_file(const char* filename) { - FILE* fd; + FILE* fd = NULL; char buffer[512]; - int value; + int value = 0; if(!(fd = fopen(filename, "r"))) return -1; @@ -68,7 +66,6 @@ int get_int_value_from_file(const char* filename) } - /*********************************************************************** * Truncates a string at the first '\r' or '\n' **********************************************************************/ @@ -84,9 +81,5 @@ void chomp(char *string) **********************************************************************/ int get_int(const char* string) { - char* first_num; - - first_num = strpbrk(string, "0123456789"); - - return atoi(first_num); + return atoi(strpbrk(string, "0123456789")); } -- cgit v1.1