]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
util: Fix base64.c linux kernel check patch errors and warnings
authorTokunori Ikegami <ikegami.t@gmail.com>
Sun, 28 May 2023 12:52:30 +0000 (21:52 +0900)
committerDaniel Wagner <wagi@monom.org>
Thu, 1 Jun 2023 17:45:53 +0000 (19:45 +0200)
Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
util/base64.c

index 07f975c8e5e858e6a2437ce633ccec04f21e97e7..7f47cda6c3cb7bab3619b473c93c430dbbb0b921 100644 (file)
@@ -81,24 +81,24 @@ int base64_decode(const char *src, int srclen, unsigned char *dst)
        int i, bits = 0;
        unsigned char *bp = dst;
 
-        for (i = 0; i < srclen; i++) {
-                const char *p = strchr(base64_table, src[i]);
+       for (i = 0; i < srclen; i++) {
+               const char *p = strchr(base64_table, src[i]);
 
-                if (src[i] == '=') {
-                        ac = (ac << 6);
+               if (src[i] == '=') {
+                       ac = (ac << 6);
                        bits += 6;
                        if (bits >= 8)
                                bits -= 8;
-                        continue;
-                }
-                if (p == NULL || src[i] == 0)
-                        return -EINVAL;
-                ac = (ac << 6) | (p - base64_table);
-                bits += 6;
-                if (bits >= 8) {
-                        bits -= 8;
-                        *bp++ = (unsigned char)(ac >> bits);
-                }
+                       continue;
+               }
+               if (!p || !src[i])
+                       return -EINVAL;
+               ac = (ac << 6) | (p - base64_table);
+               bits += 6;
+               if (bits >= 8) {
+                       bits -= 8;
+                       *bp++ = (unsigned char)(ac >> bits);
+               }
        }
        if (ac && ((1 << bits) - 1))
                return -EAGAIN;