]> git.ozlabs.org Git - ccan/commitdiff
base64: fix for unsigned chars (e.g. ARM). master
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 1 Aug 2023 01:43:53 +0000 (11:13 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 1 Aug 2023 01:43:53 +0000 (11:13 +0930)
```
ccan/ccan/base64/base64.c:34:10: error: result of comparison of constant 255 with expression of type 'int8_t' (aka 'signed char') is always false [-Werror,-Wtautological-constant-out-of-range-compare]
        if (ret == (char)0xff) {
            ~~~ ^  ~~~~~~~~~~
ccan/ccan/base64/base64.c:44:57: error: result of comparison of constant 255 with expression of type 'const signed char' is always true [-Werror,-Wtautological-constant-out-of-range-compare]
        return (maps->decode_map[(const unsigned char)b64char] != (char)0xff);
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~
```

Reported-by: Christian Decker
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ccan/base64/base64.c

index b2326293a992b45d011999a5211b4fc9fa54634e..c28e0da2a496dcbdd09abf7688caf5bbc37e117d 100644 (file)
@@ -31,7 +31,7 @@ static int8_t sixbit_from_b64(const base64_maps_t *maps,
        int8_t ret;
 
        ret = maps->decode_map[(unsigned char)b64letter];
-       if (ret == (char)0xff) {
+       if (ret == '\xff') {
                errno = EDOM;
                return -1;
        }
@@ -41,7 +41,7 @@ static int8_t sixbit_from_b64(const base64_maps_t *maps,
 
 bool base64_char_in_alphabet(const base64_maps_t *maps, const char b64char)
 {
-       return (maps->decode_map[(const unsigned char)b64char] != (char)0xff);
+       return (maps->decode_map[(const unsigned char)b64char] != '\xff');
 }
 
 void base64_init_maps(base64_maps_t *dest, const char src[64])