freedreno/rnn: Remove %n usage in fprintf
authorMark Collins <mark@igalia.com>
Mon, 7 Aug 2023 14:17:55 +0000 (14:17 +0000)
committerMarge Bot <emma+marge@anholt.net>
Wed, 13 Sep 2023 22:20:13 +0000 (22:20 +0000)
fprintf was utilized with %n to count the amount of characters it
outputted but this was redundant since it was at the end of the
statement and fprintf itself returns the amount of characters it
writes out.

It should be noted that %n is a compatibility hazard on Android as
it isn't supported on Android due to security reasons.

Signed-off-by: Mark Collins <mark@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25005>

src/freedreno/rnn/headergen2.c

index f1deb38..bb14513 100644 (file)
@@ -97,9 +97,9 @@ static void printdef (char *name, char *suf, int type, uint64_t val, char *file)
        FILE *dst = findfout(file);
        int len;
        if (suf)
-               fprintf (dst, "#define %s__%s%n", name, suf, &len);
+               len = fprintf (dst, "#define %s__%s", name, suf);
        else
-               fprintf (dst, "#define %s%n", name, &len);
+               len = fprintf (dst, "#define %s", name);
        if (type == 0 && val > 0xffffffffull)
                seekcol (dst, len, startcol-8);
        else
@@ -257,7 +257,6 @@ static void printdelem (struct rnndelem *elem, uint64_t offset, const char *str)
                        asprintf(&regname, "REG_%s", elem->fullname);
                }
                if (elemsnum) {
-                       int len;
                        FILE *dst = findfout(elem->file);
                        int i;
 
@@ -311,7 +310,7 @@ static void printdelem (struct rnndelem *elem, uint64_t offset, const char *str)
                                        fprintf(dst, "enum %s ", elems[i]->index->name);
                                else
                                        fprintf(dst, "uint32_t ");
-                               fprintf (dst, "i%d%n", i, &len);
+                               fprintf (dst, "i%d", i);
                        }
                        fprintf (dst, ") { return ");
                        fprintf (dst, "0x%08"PRIx64"", offset + elem->offset);