Tools: clang-format

This commit is contained in:
Shahram Najm 2021-02-07 22:06:42 +00:00
parent cbb523ecae
commit 2e0987aa6c
17 changed files with 62 additions and 58 deletions

View File

@ -104,7 +104,7 @@ static int listFromCommandLine;
static int verbose = 0;
static int tolerance_factor = 1;
static int write_error = 0;
static int write_count = 0;
static int write_count = 0;
static grib_handle* global_handle = NULL;
static int counter = 0;

View File

@ -65,11 +65,11 @@ grib_option grib_options[] = {
const char* tool_description = "Dump the content of a BUFR file in different formats.";
const char* tool_name = "bufr_dump";
const char* tool_usage = "[options] bufr_file bufr_file ...";
static int json = 0;
static int dump_descriptors = 0;
static char* json_option = 0;
static int first_handle = 1;
static grib_dumper* dumper = 0;
static int json = 0;
static int dump_descriptors = 0;
static char* json_option = 0;
static int first_handle = 1;
static grib_dumper* dumper = 0;
int grib_options_count = sizeof(grib_options) / sizeof(grib_option);
@ -449,7 +449,7 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h)
new_handle = grib_handle_new_from_message(0, buffer, size);
Assert(new_handle);
/* Replace handle with the new one which has only one subset */
h = new_handle;
h = new_handle;
hclone = h2; /* to be deleted later */
}
}

View File

@ -56,7 +56,7 @@ int grib_tool_init(grib_runtime_options* options)
options->action = grib_action_from_filter(options->infile_extra->name);
if (!options->action) {
const char* filt = options->infile_extra->name;
if (strcmp(filt, "-")==0) filt = "stdin";
if (strcmp(filt, "-") == 0) filt = "stdin";
fprintf(stderr, "Error: %s: unable to create action\n", filt);
exit(1);
}

View File

@ -20,7 +20,7 @@ const char* tool_description =
"\tWarning: THIS TOOL IS NOT YET IMPLEMENTED";
const char* tool_name = "bufr_index_build";
const char* tool_usage = "[options] file file ... ";
grib_index* idx = NULL;
grib_index* idx = NULL;
char* keys;
char* default_keys = "mars";

View File

@ -41,9 +41,9 @@ const char* tool_description =
"List content of BUFR files printing values of "
"some header keys.\n\tOnly scalar keys can be printed."
"\n\tIt does not fail when a key is not found.";
const char* tool_name = "bufr_ls";
const char* tool_usage = "[options] bufr_file bufr_file ...";
static int first_handle = 1;
const char* tool_name = "bufr_ls";
const char* tool_usage = "[options] bufr_file bufr_file ...";
static int first_handle = 1;
int grib_options_count = sizeof(grib_options) / sizeof(grib_option);

View File

@ -10,7 +10,7 @@
#include "grib_api_internal.h"
static int fail_on_error = 1;
static int fail_on_error = 1;
static const char* toolname = NULL;
static void usage(const char* prog)

View File

@ -113,7 +113,7 @@ int main(int argc, char* argv[])
printf("Definition files path can be changed by setting the ECCODES_DEFINITION_PATH environment variable.\n");
}
if((path = getenv("ECCODES_EXTRA_DEFINITION_PATH")) != NULL) {
if ((path = getenv("ECCODES_EXTRA_DEFINITION_PATH")) != NULL) {
printf("Environment variable ECCODES_EXTRA_DEFINITION_PATH=%s\n", path);
}
printf("\n");

View File

@ -42,9 +42,9 @@ grib_option grib_options[] = {
const char* tool_description = "Dump the content of a GRIB file in different formats.";
const char* tool_name = "grib_dump";
const char* tool_usage = "[options] grib_file grib_file ...";
static int json = 0;
static int first_handle = 1;
static int dump_keys = 0;
static int json = 0;
static int first_handle = 1;
static int dump_keys = 0;
int grib_options_count = sizeof(grib_options) / sizeof(grib_option);

View File

@ -52,7 +52,7 @@ int grib_tool_init(grib_runtime_options* options)
options->action = grib_action_from_filter(options->infile_extra->name);
if (!options->action) {
const char* filt = options->infile_extra->name;
if (strcmp(filt, "-")==0) filt = "stdin";
if (strcmp(filt, "-") == 0) filt = "stdin";
fprintf(stderr, "Error: %s: unable to create action\n", filt);
exit(1);
}

View File

@ -75,7 +75,7 @@ int grib_tool_init(grib_runtime_options* options)
if (options->latlon) {
lat = strtod(options->latlon, &theEnd);
if (*theEnd != ',') {
fprintf(stderr, "Error %s: wrong latitude value. Please use 'latitude,longitude'\n",tool_name);
fprintf(stderr, "Error %s: wrong latitude value. Please use 'latitude,longitude'\n", tool_name);
exit(1);
}
lon = strtod(++theEnd, &end1);

View File

@ -75,21 +75,21 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h)
{
int err = 0;
double missingValue = 9999;
int skip_missing = 1;
char* missing_string = NULL;
int i = 0;
grib_values* values = NULL;
grib_iterator* iter = NULL;
char* format_values = NULL;
double missingValue = 9999;
int skip_missing = 1;
char* missing_string = NULL;
int i = 0;
grib_values* values = NULL;
grib_iterator* iter = NULL;
char* format_values = NULL;
char format_latlons[32] = {0,};
char* default_format_values = "%.10e";
char* default_format_latlons = "%9.3f%9.3f";
int print_keys = grib_options_on("p:");
long numberOfPoints = 0;
long bitmapPresent = 0;
long* bitmap = NULL; /* bitmap array */
size_t bmp_len = 0;
int print_keys = grib_options_on("p:");
long numberOfPoints = 0;
long bitmapPresent = 0;
long* bitmap = NULL; /* bitmap array */
size_t bmp_len = 0;
double *data_values = 0, *lats = 0, *lons = 0;
int n = 0;
size_t size = 0, num_bytes = 0;
@ -127,7 +127,8 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h)
if (grib_options_on("F:")) {
format_values = grib_options_get_option("F:");
} else {
}
else {
format_values = default_format_values;
}
@ -139,8 +140,9 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h)
str, default_format_latlons);
exit(1);
}
sprintf(format_latlons, "%s ", str);/* Add a final space to separate from data values */
} else {
sprintf(format_latlons, "%s ", str); /* Add a final space to separate from data values */
}
else {
sprintf(format_latlons, "%s ", default_format_latlons);
}

View File

@ -88,7 +88,7 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h)
if (size > last_size) {
if (values)
free(values);
values = (double*)malloc(size * sizeof(double));
values = (double*)malloc(size * sizeof(double));
/*last_size = size;*/
if (!values) {
fprintf(stderr, "Failed to allocate memory for values (%lu bytes)\n", size * sizeof(double));

View File

@ -18,7 +18,7 @@
const char* tool_description = "Build an index file for a set of input GRIB files.";
const char* tool_name = "grib_index_build";
const char* tool_usage = "[options] grib_file grib_file ... ";
static grib_index* idx = NULL;
static grib_index* idx = NULL;
static char* keys;
static char* default_keys = "mars";

View File

@ -45,9 +45,9 @@ grib_option grib_options[] = {
const char* tool_description =
"List content of GRIB files printing values of "
"some keys.\n\tIt does not fail when a key is not found.";
const char* tool_name = "grib_ls";
const char* tool_usage = "[options] grib_file grib_file ...";
static char* new_handle = "";
const char* tool_name = "grib_ls";
const char* tool_usage = "[options] grib_file grib_file ...";
static char* new_handle = "";
int grib_options_count = sizeof(grib_options) / sizeof(grib_option);
static double lat = 0;
@ -100,7 +100,7 @@ int grib_tool_init(grib_runtime_options* options)
if (options->latlon) {
lat = strtod(options->latlon, &theEnd);
if (*theEnd != ',') {
fprintf(stderr, "Error %s: wrong latitude value. Please use 'latitude,longitude'\n",tool_name);
fprintf(stderr, "Error %s: wrong latitude value. Please use 'latitude,longitude'\n", tool_name);
exit(1);
}
lon = strtod(++theEnd, &end1);
@ -400,10 +400,10 @@ int grib_tool_finalise_action(grib_runtime_options* options)
printf("Input Point: latitude=%.2f longitude=%.2f\n", lat, lon);
if (options->latlon_idx >= 0 && options->latlon_idx < LATLON_SIZE) {
printf("Grid Point chosen #%d index=%d latitude=%.2f longitude=%.2f distance=%.2f (Km)\n",
options->latlon_idx + 1, (int)options->indexes[options->latlon_idx],
options->lats[options->latlon_idx],
options->lons[options->latlon_idx],
options->distances[options->latlon_idx]);
options->latlon_idx + 1, (int)options->indexes[options->latlon_idx],
options->lats[options->latlon_idx],
options->lons[options->latlon_idx],
options->distances[options->latlon_idx]);
}
if (options->latlon_mask) {
printf("Mask values:\n");

View File

@ -333,7 +333,7 @@ int grib_process_runtime_options(grib_context* context, int argc, char** argv, g
}
options->requested_print_keys_count = MAX_KEYS;
ret = parse_keyval_string(tool_name, karg, 0, GRIB_TYPE_UNDEFINED,
ret = parse_keyval_string(tool_name, karg, 0, GRIB_TYPE_UNDEFINED,
options->requested_print_keys, &(options->requested_print_keys_count));
if (ret == GRIB_INVALID_ARGUMENT)
usage();
@ -437,7 +437,8 @@ char* grib_options_get_args(char* id)
if (grib_options[i].args != NULL) {
free(err);
return grib_options[i].args;
} else {
}
else {
break;
}
}
@ -447,7 +448,8 @@ char* grib_options_get_args(char* id)
if (grib_options_help_list[i].args != NULL) {
free(err);
return (char*)grib_options_help_list[i].args;
} else {
}
else {
return err;
}
}

View File

@ -32,8 +32,8 @@ const char* tool_description =
"Convert a GRIB file to netCDF format."
"\n\tNote: The GRIB geometry should be a regular lat/lon grid or a regular Gaussian grid"
"\n\t(the key \"typeOfGrid\" should be \"regular_ll\" or \"regular_gg\")";
const char* tool_name = "grib_to_netcdf";
const char* tool_usage = "[options] grib_file grib_file ... ";
const char* tool_name = "grib_to_netcdf";
const char* tool_usage = "[options] grib_file grib_file ... ";
static char argvString[2048] = {0,};
/*=====================================================================*/
@ -2245,7 +2245,7 @@ static int def_latlon(int ncid, fieldset* fs)
{
int n = 0;
size_t nlats = 0, nlons = 0;
err e = 0;
err e = 0;
field* g = get_field(fs, 0, expand_mem);
@ -2257,11 +2257,11 @@ static int def_latlon(int ncid, fieldset* fs)
}
/* Define longitude */
n = (int)nlons;
n = (int)nlons;
set_dimension(ncid, "longitude", n, NC_FLOAT, "degrees_east", "longitude");
/* Define latitude */
n = nlats;
n = nlats;
set_dimension(ncid, "latitude", n, NC_FLOAT, "degrees_north", "latitude");
/* g->purge_header = TRUE; */
@ -2634,8 +2634,8 @@ static void scale(double* vals, long n, void* data, dataset_t* g)
}
*/
DebugAssert(vals);
DebugAssert(n>0);
if(!vals) return;
DebugAssert(n > 0);
if (!vals) return;
switch (nctype) {
case NC_BYTE: {

View File

@ -88,14 +88,14 @@ static int headerMode = 0;
static int morein1 = 0;
static int morein2 = 0;
static int listFromCommandLine;
static int verbose = 0;
static int tolerance_factor = 1;
static int write_error = 0;
static int verbose = 0;
static int tolerance_factor = 1;
static int write_error = 0;
static grib_handle* global_handle = NULL;
static int global_counter = 0;
static int start = -1;
static int end = -1;
static int write_count = 0;
static int write_count = 0;
GRIB_INLINE static double compare_double_absolute(double* a, double* b, double* err)
{