]> git.ipfire.org Git - thirdparty/git.git/commitdiff
pretty: add casts for decoration option pointers
authorPatrick Steinhardt <ps@pks.im>
Fri, 7 Jun 2024 06:38:39 +0000 (08:38 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 7 Jun 2024 17:30:52 +0000 (10:30 -0700)
The `struct decoration_options` have a prefix and suffix field which are
both non-constant, but we assign a constant pointer to them. This is
safe to do because we pass them to `format_decorations()`, which never
modifies these pointers, and then immediately discard the structure. Add
explicit casts to avoid compilation warnings with `-Wwrite-strings`.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
pretty.c

index ec05db5655b165ab7a394724cc938e68ed98b27d..1df9d635fbe2e2f2b15ecbacb32bc6c9b485635a 100644 (file)
--- a/pretty.c
+++ b/pretty.c
@@ -1584,8 +1584,8 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */
        case 'D':
                {
                        const struct decoration_options opts = {
-                               .prefix = "",
-                               .suffix = ""
+                               .prefix = (char *) "",
+                               .suffix = (char *) "",
                        };
 
                        format_decorations(sb, commit, c->auto_color, &opts);