GNU bug report logs - #78659
[PATCH] Pacify Clang's -Wformat-signedness.

Previous Next

Package: emacs;

Reported by: Collin Funk <collin.funk1 <at> gmail.com>

Date: Sun, 1 Jun 2025 05:17:05 UTC

Severity: normal

Tags: patch

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Collin Funk <collin.funk1 <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Pacify Clang's -Wformat-signedness.
Date: Sat, 31 May 2025 22:16:15 -0700
[Message part 1 (text/plain, inline)]
Hi,

When compiling with './autogen.sh && ./configure CC=clang && make':

    [...]
    xfns.c:2041:6: warning: format specifies type 'unsigned int' but the argument has type 'int' [-Wformat]
     2040 |           sprintf (css, "scrollbar slider { background-color: #%02x%02x%02x; }",
          |                                                                ~~~~
          |                                                                %02x
     2041 |                    color.red >> 8, color.green >> 8, color.blue >> 8);
    [...]

This warning is harmless, but interestingly 'gcc -Wformat-signedness'
does not warn about it, but 'clang -Wformat-signedness' does.

Since the color fields of struct XColor are 'unsigned short' and the
constant is an 'int', the expression should be an 'int'.

Anyways, the attached patch silences the warnings.

Collin

[0001-Pacify-Clang-s-Wformat-signedness.patch (text/x-patch, attachment)]

This bug report was last modified 11 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.