Mark read-only global shared data as const

This commit is contained in:
Shahram Najm 2018-05-29 17:44:13 +01:00
parent c098dfe125
commit 029e7367e2
21 changed files with 44 additions and 37 deletions

View File

@ -256,11 +256,21 @@ static void restart_bitmap(grib_accessor_bufr_data_array *self)
self->bitmapCurrentElementsDescriptorsIndex=self->bitmapStartElementsDescriptorsIndex-1;
}
static void cancel_bitmap(grib_accessor_bufr_data_array *self) { self->bitmapCurrent=-1;self->bitmapStart=-1; }
static void cancel_bitmap(grib_accessor_bufr_data_array *self)
{
self->bitmapCurrent=-1;
self->bitmapStart=-1;
}
static int is_bitmap_start_defined(grib_accessor_bufr_data_array *self) { return self->bitmapStart==-1 ? 0 : 1; }
static int is_bitmap_start_defined(grib_accessor_bufr_data_array *self)
{
return self->bitmapStart==-1 ? 0 : 1;
}
int accessor_bufr_data_array_create_keys(grib_accessor* a,long onlySubset,long startSubset,long endSubset) { return create_keys(a,onlySubset,startSubset,endSubset); }
int accessor_bufr_data_array_create_keys(grib_accessor* a,long onlySubset,long startSubset,long endSubset)
{
return create_keys(a,onlySubset,startSubset,endSubset);
}
int accessor_bufr_data_array_process_elements(grib_accessor* a,int flag,long onlySubset,long startSubset,long endSubset)
{
@ -1891,7 +1901,7 @@ static grib_accessor* create_accessor_from_descriptor(grib_accessor* a,grib_acce
#define NUMBER_OF_QUALIFIERS_CATEGORIES 7
#define MAX_NUMBER_OF_BITMAPS 5
static int number_of_qualifiers=NUMBER_OF_QUALIFIERS_PER_CATEGORY*NUMBER_OF_QUALIFIERS_CATEGORIES;
static const int number_of_qualifiers=NUMBER_OF_QUALIFIERS_PER_CATEGORY*NUMBER_OF_QUALIFIERS_CATEGORIES;
static GRIB_INLINE int significanceQualifierIndex(int X,int Y)
{

View File

@ -185,7 +185,7 @@ static void init(grib_accessor* a, const long len , grib_arguments* arg )
self->numberOfDataPoints = grib_arguments_get_name(grib_handle_of_accessor(a),arg,n++);
}
static int used[] ={ 0,1,3,7,15,31,63,127,255};
static const int used[] ={ 0,1,3,7,15,31,63,127,255};
static int unpack_long (grib_accessor* a, long* val, size_t *len)
{

View File

@ -204,7 +204,7 @@ static void init_class(grib_accessor_class* c)
#define MAX_NUMBER_OF_GROUPS 65534
#define EFDEBUG 0
static unsigned long nbits[64]={
static const unsigned long nbits[64]={
0x1, 0x2, 0x4, 0x8,
0x10, 0x20, 0x40, 0x80,
0x100, 0x200, 0x400, 0x800,
@ -225,7 +225,7 @@ static unsigned long nbits[64]={
static long number_of_bits(grib_handle*h, unsigned long x)
{
unsigned long *n=nbits;
const unsigned long *n=nbits;
const int count = sizeof(nbits)/sizeof(nbits[0]);
long i=0;
while (x>=*n) {

View File

@ -181,7 +181,7 @@ static void init(grib_accessor* a,const long v, grib_arguments* args)
self->dirty=1;
}
static unsigned long nbits[32]={
static const unsigned long nbits[32]={
0x1, 0x2, 0x4, 0x8, 0x10, 0x20,
0x40, 0x80, 0x100, 0x200, 0x400, 0x800,
0x1000, 0x2000, 0x4000, 0x8000, 0x10000, 0x20000,
@ -193,7 +193,7 @@ static unsigned long nbits[32]={
static int number_of_bits(unsigned long x, long* result)
{
const int count = sizeof(nbits)/sizeof(nbits[0]);
unsigned long *n=nbits;
const unsigned long *n=nbits;
*result=0;
while (x >= *n) {
n++;

View File

@ -180,10 +180,9 @@ static void init(grib_accessor* a,const long l, grib_arguments* c)
static void dump(grib_accessor* a, grib_dumper* dumper)
{
grib_dump_string(dumper,a,NULL);
}
static int u2s1[] = {
static const int u2s1[] = {
60, /* (0) minutes */
3600, /* (1) hour */
86400, /* (2) day */
@ -202,11 +201,11 @@ static int u2s1[] = {
1 /* (15) seconds */ /* See ECC-316 */
};
static int units_index[] = {
static const int units_index[] = {
1,0,10,11,12,2,0,13,14,15
};
static int u2s[] = {
static const int u2s[] = {
60, /* (0) minutes */
3600, /* (1) hour */
86400, /* (2) day */

View File

@ -202,7 +202,7 @@ static void dump(grib_accessor* a, grib_dumper* dumper)
grib_dump_double(dumper,a,NULL);
}
static int u2s2[] = {
static const int u2s2[] = {
60, /* (0) minutes */
3600, /* (1) hour */
86400, /* (2) day */
@ -219,7 +219,7 @@ static int u2s2[] = {
1 /* (13) seconds */
};
static int u2s[] = {
static const int u2s[] = {
60, /* (0) minutes */
3600, /* (1) hour */
86400, /* (2) day */

View File

@ -146,7 +146,7 @@ static void dump(grib_accessor* a, grib_dumper* dumper)
grib_dump_double(dumper,a,NULL);
}
static int units[] = {
static const int units[] = {
0, /* (0) minutes */
1, /* (1) hour */
24, /* (2) day */

View File

@ -141,7 +141,7 @@ static void init_class(grib_accessor_class* c)
/* END_CLASS_IMP */
/*
static unsigned long nbits[32]={
static const unsigned long nbits[32]={
0x1, 0x2, 0x4, 0x8, 0x10, 0x20,
0x40, 0x80, 0x100, 0x200, 0x400, 0x800,
0x1000, 0x2000, 0x4000, 0x8000, 0x10000, 0x20000,
@ -150,7 +150,7 @@ static unsigned long nbits[32]={
0x40000000, 0x80000000
};
*/
static unsigned long nbits[64]={
static const unsigned long nbits[64]={
0x1, 0x2, 0x4, 0x8,
0x10, 0x20, 0x40, 0x80,
0x100, 0x200, 0x400, 0x800,
@ -171,7 +171,7 @@ static unsigned long nbits[64]={
static int number_of_bits(unsigned long x, long* result)
{
unsigned long *n=nbits;
const unsigned long *n=nbits;
const int count = sizeof(nbits)/sizeof(nbits[0]);
*result=0;
while (x>=*n) {

View File

@ -148,7 +148,6 @@ static void init(grib_accessor* a, const long len , grib_arguments* arg )
a->length = len * count;
self->nbytes = len;
Assert(a->length>=0);
}
static void dump(grib_accessor* a, grib_dumper* dumper)
@ -161,7 +160,7 @@ static void dump(grib_accessor* a, grib_dumper* dumper)
grib_dump_values(dumper,a);
}
static long ones[] = {
static const long ones[] = {
0,
-0x7f,
-0x7fff,
@ -169,7 +168,6 @@ static long ones[] = {
-0x7fffffff,
};
static int unpack_long(grib_accessor* a, long* val, size_t *len)
{

View File

@ -158,7 +158,7 @@ static void dump(grib_accessor* a, grib_dumper* dumper)
}
/* Conversion of to seconds - Grib edition 2 table 4.4 */
static int u2s2[] = {
static const int u2s2[] = {
60, /* (0) minutes */
3600, /* (1) hour */
86400, /* (2) day */
@ -176,7 +176,7 @@ static int u2s2[] = {
};
/* Note: 'stepUnits' has a different table with extra entries e.g. 15 and 30 mins */
static int u2s[] = {
static const int u2s[] = {
60, /* (0) minutes */
3600, /* (1) hour */
86400, /* (2) day */

View File

@ -170,7 +170,7 @@ static void dump(grib_accessor* a, grib_dumper* dumper)
grib_dump_values(dumper,a);
}
static unsigned long ones[] = {
static const unsigned long ones[] = {
0,
0xff,
0xffff,

View File

@ -30,9 +30,9 @@ long GRIB_MASK = -1; /* Mask of sword bits */
((b)==max_nbits ? GRIB_MASK : (~(GRIB_MASK<<(b))<<(max_nbits-((q)+(b)))))
static unsigned long dmasks[] = { 0xFF, 0xFE, 0xFC, 0xF8, 0xF0, 0xE0, 0xC0, 0x80, 0x00, };
static const unsigned long dmasks[] = { 0xFF, 0xFE, 0xFC, 0xF8, 0xF0, 0xE0, 0xC0, 0x80, 0x00, };
static int max_nbits = sizeof(unsigned long)*8;
static const int max_nbits = sizeof(unsigned long)*8;
unsigned long grib_decode_unsigned_byte_long(const unsigned char* p, long o, int l)
{

View File

@ -21,7 +21,7 @@ struct table_entry
grib_box_class **cclass;
};
static struct table_entry table[] =
static const struct table_entry table[] =
{
/* This file is generated by ./make_class.pl */
#include "grib_box_factory.h"

View File

@ -10673,7 +10673,7 @@ grib_keys_hash_get (const char *str, unsigned int len)
* Enrico Fucile
**************************************/
static int mapping[] = {
static const int mapping[] = {
0, /* 00 */
0, /* 01 */
0, /* 02 */

View File

@ -27,7 +27,7 @@ struct table_entry
grib_iterator_class **cclass;
};
static struct table_entry table[] =
static const struct table_entry table[] =
{
/* This file is generated by ./make_class.pl */
#include "grib_iterator_factory.h"

View File

@ -11,7 +11,7 @@
#include "grib_api_internal.h"
/* Note: all non-alpha are mapped to 0 */
static int mapping[] = {
static const int mapping[] = {
0, /* 00 */
0, /* 01 */
0, /* 02 */

View File

@ -12,7 +12,7 @@
* Enrico Fucile
**************************************/
static int mapping[] = {
static const int mapping[] = {
0, /* 00 */
0, /* 01 */
0, /* 02 */

View File

@ -26,7 +26,7 @@ struct table_entry
grib_nearest_class **cclass;
};
static struct table_entry table[] =
static const struct table_entry table[] =
{
/* This file is generated by ./make_class.pl */
#include "grib_nearest_factory.h"

View File

@ -11,7 +11,7 @@
#include "grib_api_internal.h"
/* Note: all non-alpha are mapped to 0 */
static int mapping[] = {
static const int mapping[] = {
0, /* 00 */
0, /* 01 */
0, /* 02 */

View File

@ -11,7 +11,7 @@
#include "grib_api_internal.h"
/* Note: all non-alpha are mapped to 0 */
static int mapping[] = {
static const int mapping[] = {
0, /* 00 */
0, /* 01 */
0, /* 02 */

View File

@ -19,13 +19,13 @@
#pragma _CRI noopt
#endif
static unsigned long r[] = {
static const unsigned long r[] = {
7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22,
5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20,
4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23,
6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21};
static unsigned long k[] = {
static const unsigned long k[] = {
0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be, 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,
0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa, 0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8,