Fossil SCM

Misuse of a potentially unsigned value, caught by clang. Only affected platforms where char is unsigned by default.

stephan 2020-09-17 19:31 trunk
Commit 5c92bbfca7e36751b81ee28ce52de05d432028e0a05ae33604239084594c1538
1 file changed +2 -2
+2 -2
--- src/json_user.c
+++ src/json_user.c
@@ -398,11 +398,11 @@
398398
static cson_value * json_user_save(){
399399
/* try to get user info from GET/CLI args and construct
400400
a JSON form of it... */
401401
cson_object * u = cson_new_object();
402402
char const * str = NULL;
403
- char b = -1;
403
+ int b = -1;
404404
int i = -1;
405405
int uid = -1;
406406
cson_value * payload = NULL;
407407
/* String properties... */
408408
#define PROP(LK,SK) str = json_find_option_cstr(LK,NULL,SK); \
@@ -412,11 +412,11 @@
412412
PROP("info","i");
413413
PROP("capabilities","c");
414414
#undef PROP
415415
/* Boolean properties... */
416416
#define PROP(LK,DFLT) b = json_find_option_bool(LK,NULL,NULL,DFLT); \
417
- if(DFLT!=b){ cson_object_set(u, LK, cson_value_new_bool(b)); } (void)0
417
+ if(DFLT!=b){ cson_object_set(u, LK, cson_value_new_bool(b ? 1 : 0)); } (void)0
418418
PROP("forceLogout",-1);
419419
#undef PROP
420420
421421
#define PROP(LK,DFLT) i = json_find_option_int(LK,NULL,NULL,DFLT); \
422422
if(DFLT != i){ cson_object_set(u, LK, cson_value_new_integer(i)); } (void)0
423423
--- src/json_user.c
+++ src/json_user.c
@@ -398,11 +398,11 @@
398 static cson_value * json_user_save(){
399 /* try to get user info from GET/CLI args and construct
400 a JSON form of it... */
401 cson_object * u = cson_new_object();
402 char const * str = NULL;
403 char b = -1;
404 int i = -1;
405 int uid = -1;
406 cson_value * payload = NULL;
407 /* String properties... */
408 #define PROP(LK,SK) str = json_find_option_cstr(LK,NULL,SK); \
@@ -412,11 +412,11 @@
412 PROP("info","i");
413 PROP("capabilities","c");
414 #undef PROP
415 /* Boolean properties... */
416 #define PROP(LK,DFLT) b = json_find_option_bool(LK,NULL,NULL,DFLT); \
417 if(DFLT!=b){ cson_object_set(u, LK, cson_value_new_bool(b)); } (void)0
418 PROP("forceLogout",-1);
419 #undef PROP
420
421 #define PROP(LK,DFLT) i = json_find_option_int(LK,NULL,NULL,DFLT); \
422 if(DFLT != i){ cson_object_set(u, LK, cson_value_new_integer(i)); } (void)0
423
--- src/json_user.c
+++ src/json_user.c
@@ -398,11 +398,11 @@
398 static cson_value * json_user_save(){
399 /* try to get user info from GET/CLI args and construct
400 a JSON form of it... */
401 cson_object * u = cson_new_object();
402 char const * str = NULL;
403 int b = -1;
404 int i = -1;
405 int uid = -1;
406 cson_value * payload = NULL;
407 /* String properties... */
408 #define PROP(LK,SK) str = json_find_option_cstr(LK,NULL,SK); \
@@ -412,11 +412,11 @@
412 PROP("info","i");
413 PROP("capabilities","c");
414 #undef PROP
415 /* Boolean properties... */
416 #define PROP(LK,DFLT) b = json_find_option_bool(LK,NULL,NULL,DFLT); \
417 if(DFLT!=b){ cson_object_set(u, LK, cson_value_new_bool(b ? 1 : 0)); } (void)0
418 PROP("forceLogout",-1);
419 #undef PROP
420
421 #define PROP(LK,DFLT) i = json_find_option_int(LK,NULL,NULL,DFLT); \
422 if(DFLT != i){ cson_object_set(u, LK, cson_value_new_integer(i)); } (void)0
423

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button