diff --git a/tests/grib_multi_from_message.c b/tests/grib_multi_from_message.c index d511e5395..8eed585ac 100644 --- a/tests/grib_multi_from_message.c +++ b/tests/grib_multi_from_message.c @@ -9,7 +9,7 @@ */ /* - * test: reading multi fields messages from memory + * test: reading GRIB2 multi fields messages from memory */ #include "grib_api.h" @@ -20,15 +20,17 @@ #include #endif -static void usage(const char* prog) { - printf("usage: %s [-m] file.grib\n",prog); +static void usage(const char* prog) +{ + fprintf(stderr, "usage: %s [-m] file.grib\n", prog); exit(1); } -int main(int argc,char* argv[]) { +int main(int argc,char* argv[]) +{ struct stat finfo; char shortName[20]={0,}; - size_t len=20; + size_t len; grib_handle* h=NULL; size_t fsize; unsigned char* data=NULL; @@ -52,7 +54,7 @@ int main(int argc,char* argv[]) { f=fopen(filename,"rb"); if (!f) {perror(filename);exit(1);} - fstat(fileno((FILE*)f),&finfo); + stat(filename, &finfo); fsize=finfo.st_size; data=(unsigned char*)malloc(fsize);