@@ -31,7 +31,7 @@ GRIB_INLINE static int grib_inline_strcmp(const char* a, const char* b)
31
31
return (*a == 0 && *b == 0 ) ? 0 : 1 ;
32
32
}
33
33
34
- /* Debug utility function to track GRIB packing/repacking issues */
34
+ // Debug utility function to track GRIB packing/repacking issues
35
35
template <typename T>
36
36
static void print_debug_info__set_array (grib_handle* h, const char * func, const char * name, const T* val, size_t length)
37
37
{
@@ -339,7 +339,7 @@ int grib_copy_namespace(grib_handle* dest, const char* name, grib_handle* src)
339
339
}
340
340
}
341
341
if (err)
342
- error_code = *err; /* copy the error code before cleanup */
342
+ error_code = *err; // copy the error code before cleanup
343
343
grib_keys_iterator_delete (iter);
344
344
key_err = first;
345
345
while (key_err) {
@@ -407,9 +407,8 @@ int grib_set_string_internal(grib_handle* h, const char* name,
407
407
return GRIB_NOT_FOUND;
408
408
}
409
409
410
- /* Return 1 if we dealt with specific packing type changes and nothing more needs doing.
411
- * Return 0 if further action is needed
412
- */
410
+ // Return 1 if we dealt with specific packing type changes and nothing more needs doing.
411
+ // Return 0 if further action is needed
413
412
static int preprocess_packingType_change (grib_handle* h, const char * keyname, const char * keyval)
414
413
{
415
414
int err = 0 ;
@@ -488,7 +487,7 @@ int grib_set_string(grib_handle* h, const char* name, const char* val, size_t* l
488
487
489
488
int processed = preprocess_packingType_change (h, name, val);
490
489
if (processed)
491
- return GRIB_SUCCESS; /* Dealt with - no further action needed */
490
+ return GRIB_SUCCESS; // Dealt with - no further action needed
492
491
493
492
a = grib_find_accessor (h, name);
494
493
@@ -566,8 +565,8 @@ int grib_set_bytes(grib_handle* h, const char* name, const unsigned char* val, s
566
565
grib_accessor* a = grib_find_accessor (h, name);
567
566
568
567
if (a) {
569
- /* if(a->flags_ & GRIB_ACCESSOR_FLAG_READ_ONLY) */
570
- /* return GRIB_READ_ONLY; */
568
+ // if(a->flags_ & GRIB_ACCESSOR_FLAG_READ_ONLY)
569
+ // return GRIB_READ_ONLY;
571
570
572
571
ret = a->pack_bytes (val, length);
573
572
if (ret == GRIB_SUCCESS) {
@@ -639,14 +638,14 @@ int grib_is_missing_double(grib_accessor* a, double x)
639
638
640
639
int grib_is_missing_string (grib_accessor* a, const unsigned char * x, size_t len)
641
640
{
642
- /* For a string value to be missing, every character has to be */
643
- /* all 1's (i.e. 0xFF) */
644
- /* Note: An empty string is also classified as missing */
641
+ // For a string value to be missing, every character has to be */
642
+ // all 1's (i.e. 0xFF) */
643
+ // Note: An empty string is also classified as missing */
645
644
int ret;
646
645
size_t i = 0 ;
647
646
648
647
if (len == 0 )
649
- return 1 ; /* empty string */
648
+ return 1 ; // empty string
650
649
ret = 1 ;
651
650
for (i = 0 ; i < len; i++) {
652
651
if (x[i] != 0xFF ) {
@@ -695,7 +694,7 @@ int grib_is_missing(const grib_handle* h, const char* name, int* err)
695
694
return grib_accessor_is_missing (a, err);
696
695
}
697
696
698
- /* Return true if the given key exists (is defined) in our grib message */
697
+ // Return true if the given key exists (is defined) in our grib message
699
698
int grib_is_defined (const grib_handle* h, const char * name)
700
699
{
701
700
const grib_accessor* a = grib_find_accessor (h, name);
@@ -729,7 +728,7 @@ static int _grib_set_double_array_internal(grib_handle* h, grib_accessor* a,
729
728
err = a->pack_double (val + *encoded_length, &len);
730
729
*encoded_length += len;
731
730
if (err == GRIB_SUCCESS) {
732
- /* See ECC-778 */
731
+ // See ECC-778
733
732
return grib_dependency_notify_change_h (h, a);
734
733
}
735
734
}
@@ -768,7 +767,7 @@ static int _grib_set_double_array(grib_handle* h, const char* name,
768
767
err = GRIB_ARRAY_TOO_SMALL;
769
768
770
769
if (err == GRIB_SUCCESS)
771
- return grib_dependency_notify_change_h (h, a); /* See ECC-778 */
770
+ return grib_dependency_notify_change_h (h, a); // See ECC-778
772
771
773
772
return err;
774
773
}
@@ -792,7 +791,7 @@ int grib_set_double_array_internal(grib_handle* h, const char* name, const doubl
792
791
if (ret != GRIB_SUCCESS)
793
792
grib_context_log (h->context , GRIB_LOG_ERROR, " Unable to set double array '%s' (%s)" ,
794
793
name, grib_get_error_message (ret));
795
- /* if (h->context->debug) fprintf(stderr,"ECCODES DEBUG grib_set_double_array_internal key=%s --DONE\n",name);*/
794
+ // if (h->context->debug) fprintf(stderr,"ECCODES DEBUG grib_set_double_array_internal key=%s --DONE\n",name);
796
795
return ret;
797
796
}
798
797
@@ -1784,6 +1783,12 @@ int grib_get_long_array(const grib_handle* h, const char* name, long* val, size_
1784
1783
// }
1785
1784
1786
1785
int grib_set_values (grib_handle* h, grib_values* args, size_t count)
1786
+ {
1787
+ // The default behaviour is to print any error messages (not silent)
1788
+ return grib_set_values_silent (h, args, count, /* silent=*/ 0 );
1789
+ }
1790
+
1791
+ int grib_set_values_silent (grib_handle* h, grib_values* args, size_t count, int silent)
1787
1792
{
1788
1793
int i, error = 0 ;
1789
1794
int err = 0 ;
@@ -1839,13 +1844,13 @@ int grib_set_values(grib_handle* h, grib_values* args, size_t count)
1839
1844
break ;
1840
1845
1841
1846
default :
1842
- grib_context_log (h->context , GRIB_LOG_ERROR, " grib_set_values[%d] %s invalid type %d" , i, args[i].name , args[i].type );
1847
+ if (!silent)
1848
+ grib_context_log (h->context , GRIB_LOG_ERROR, " grib_set_values[%d] %s invalid type %d" , i, args[i].name , args[i].type );
1843
1849
args[i].error = GRIB_INVALID_ARGUMENT;
1844
1850
break ;
1845
1851
}
1846
- /* if (args[i].error != GRIB_SUCCESS)
1847
- grib_context_log(h->context,GRIB_LOG_ERROR,"Unable to set %s (%s)",
1848
- args[i].name,grib_get_error_message(args[i].error)); */
1852
+ // if (args[i].error != GRIB_SUCCESS)
1853
+ // grib_context_log(h->context,GRIB_LOG_ERROR,"Unable to set %s (%s)",args[i].name,grib_get_error_message(args[i].error));
1849
1854
}
1850
1855
}
1851
1856
@@ -1856,10 +1861,12 @@ int grib_set_values(grib_handle* h, grib_values* args, size_t count)
1856
1861
1857
1862
for (i = 0 ; i < count; i++) {
1858
1863
if (args[i].error != GRIB_SUCCESS) {
1859
- grib_context_log (h->context , GRIB_LOG_ERROR,
1860
- " grib_set_values[%d] %s (type=%s) failed: %s (message %d)" ,
1861
- i, args[i].name , grib_get_type_name (args[i].type ),
1862
- grib_get_error_message (args[i].error ), h->context ->handle_file_count );
1864
+ if (!silent) {
1865
+ grib_context_log (h->context , GRIB_LOG_ERROR,
1866
+ " grib_set_values[%d] %s (type=%s) failed: %s (message %d)" ,
1867
+ i, args[i].name , grib_get_type_name (args[i].type ),
1868
+ grib_get_error_message (args[i].error ), h->context ->handle_file_count );
1869
+ }
1863
1870
err = err == GRIB_SUCCESS ? args[i].error : err;
1864
1871
}
1865
1872
}
0 commit comments