diff options
author | David Phillips <dbphillipsnz@gmail.com> | 2015-09-01 21:19:01 +1200 |
---|---|---|
committer | David Phillips <dbphillipsnz@gmail.com> | 2015-09-01 21:39:20 +1200 |
commit | 32bff14871bf8f534fcdcdba1d8409430d6c464b (patch) | |
tree | 6de6cd2cda5cc91d76ae2fac8764270a01cb260c /common.c | |
parent | 841445fb7a482b9c1ed9eca896d308afab4316d8 (diff) | |
download | paramano-32bff14871bf8f534fcdcdba1d8409430d6c464b.tar.xz |
Conforming to style, switching paramano-set to getopt (finally)
Diffstat (limited to 'common.c')
-rw-r--r-- | common.c | 13 |
1 files changed, 3 insertions, 10 deletions
@@ -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")); } |