]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
tools/asn1_compiler: avoid -Wdiscarded-qualifiers
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Sat, 18 Apr 2026 06:32:13 +0000 (08:32 +0200)
committerTom Rini <trini@konsulko.com>
Fri, 24 Apr 2026 17:28:17 +0000 (11:28 -0600)
Building with GCC 15.2 results in warnings:

    tools/asn1_compiler.c: In function ‘tokenise’:
    tools/asn1_compiler.c:442:37: warning:
    assignment discards ‘const’ qualifier from pointer target type
    [-Wdiscarded-qualifiers]
      442 |             dir = bsearch(&tokens[tix], directives,
          |                 ^

    tools/asn1_compiler.c: In function ‘main’:
    tools/asn1_compiler.c:632:11: warning:
    assignment discards ‘const’ qualifier from pointer target type
    [-Wdiscarded-qualifiers]
      632 |         p = strchr(grammar_name, '.');
          |           ^

bsearch() is defined as

       void *bsearch(size_t n, size_t size;
                     const void key[size], const void base[size * n],
                     size_t n, size_t size,
                     typeof(int (const void [size], const void [size]))
                         *compar);

* Use the correct type for dir.

strchr() is defined as

        char *strchr(const char *s, int c).

* Use a conversion for the assignment to p.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
tools/asn1_compiler.c

index 03fb7e03758f64b72f3707d49283109776a3c0cf..c2ca467e18ff286b3bbee9a458cc2e64b8915c47 100644 (file)
@@ -409,7 +409,7 @@ static void tokenise(char *buffer, char *end)
 
                        /* Handle string tokens */
                        if (isalpha(*p)) {
-                               const char **dir;
+                               const char * const *dir;
 
                                /* Can be a directive, type name or element
                                 * name.  Find the end of the name.
@@ -629,7 +629,7 @@ int main(int argc, char **argv)
                perror(NULL);
                exit(1);
        }
-       p = strchr(grammar_name, '.');
+       p = (char *)strchr(grammar_name, '.');
        if (p)
                *p = '\0';