Refactoring, indentation clean up etc

This commit is contained in:
Shahram Najm 2013-06-21 13:14:22 +01:00
parent 467a2c0ea6
commit e770c0abcd
5 changed files with 13 additions and 23 deletions

View File

@ -143,6 +143,7 @@ static int test_bit(long a, long b)
{
return a&(1<<b);
}
static int grib_get_codeflag(grib_accessor* a, long code, char* codename)
{
grib_accessor_codeflag* self = (grib_accessor_codeflag*)a;
@ -152,7 +153,7 @@ static int grib_get_codeflag(grib_accessor* a, long code, char* codename)
char num[50];
char* filename=0;
char line[1024];
int i =0;
size_t i =0;
int j =0;
grib_recompose_name(a->parent->h,NULL, self->tablename, fname,1);
@ -183,9 +184,10 @@ static int grib_get_codeflag(grib_accessor* a, long code, char* codename)
sscanf(line,"%s %s", num, bval);
if(num[0] != '#')
{
if((test_bit(code, a->length*8-atol(num))>0) == atol(bval))
{
#if 1
size_t linelen = strlen(line);
codename[j++] = '(';
codename[j++] = num[0];
codename[j++] = '=';
@ -194,15 +196,16 @@ static int grib_get_codeflag(grib_accessor* a, long code, char* codename)
codename[j++] = ' ';
if(j)
codename[j++] = ' ';
#endif
for(i=(strlen(num)+strlen(bval)+2); i < strlen(line)-1;i++)
for(i=(strlen(num)+strlen(bval)+2); i < linelen-1;i++)
codename[j++] = line[i];
if(line[i]!='\n')
codename[j++] = line[i];
codename[j++] = ';';
}
}
}
if(j>1 && codename[j-1] == ';') j--;
codename[j] = 0;
@ -212,6 +215,7 @@ static int grib_get_codeflag(grib_accessor* a, long code, char* codename)
fclose(f);
return GRIB_SUCCESS;
}
static long value_count(grib_accessor* a)
{
return 1;
@ -233,6 +237,4 @@ static void dump(grib_accessor* a, grib_dumper* dumper)
grib_dump_bits(dumper,a,flagname);
}

View File

@ -260,7 +260,7 @@ static int find_next_group(const unsigned long* vals, size_t len, unsigned long
while(i < len){
if(vals[i] < lmin) lmin = vals[i];
if(vals[i] > lmax) lmax = vals[i];
Assert((lmax-lmin) >= 0);
/*Assert((lmax-lmin) >= 0);*/
*nbits = calc_bits_needed(lmax-lmin);
*r_val = lmin;
i++;

View File

@ -149,7 +149,7 @@ static int pack_double(grib_accessor* a, const double* val,size_t *len){
size_t tlen;
unsigned char* buf = NULL;
long i;
size_t i;
int err = 0;
long pos = 0;
long bmaplen = 0;
@ -208,7 +208,7 @@ static int unpack_bytes(grib_accessor* a, unsigned char* val, size_t *len)
long length = grib_byte_count(a);
long offset = grib_byte_offset(a);
if(*len < length )
if(*len < (size_t)length )
{
grib_context_log(a->parent->h->context, GRIB_LOG_ERROR, "Wrong size for %s it is %d bytes long\n", a->name ,length );
*len = length;
@ -233,5 +233,3 @@ static void grib_set_bit_on( unsigned char* p, long *bitp){
*p |= o;
(*bitp)+=1;
}

View File

@ -155,7 +155,7 @@ static int pack_double(grib_accessor* a, const double* val,size_t *len){
size_t tlen;
unsigned char* buf = NULL;
long i;
size_t i;
int err = 0;
long pos = 0;
long bmaplen = 0;

View File

@ -1,15 +1,5 @@
/* This file is automatically generated by ./errors.pl, do not edit */
/*
* Copyright 2005-2013 ECMWF.
*
* This software is licensed under the terms of the Apache Licence Version 2.0
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
*
* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
*/
#include "grib_api_internal.h"
static const char *errors[] = {