MantisBT - LibCSS
View Issue Details
0002870LibCSSLibCSSpublic2024-03-09 04:212024-05-25 11:14
ReporterRichard Bauer 
Assigned ToVincent Sanders 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
Platformi686-linuxOSGNU GuixOS Version
Fixed in CI build #
Reported in CI build #
Summary0002870: 0.9.2 tests fail to build on 32-bit system
DescriptionWhen attempting to compile libcss tests for a i686-linux system, I get the following error:

```
In file included from test/css21.c:11:
test/dump.h: In function ‘dump_rule_media’:
test/dump.h:134:45: error: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Werror=format=]
  134 | ptr += sprintf(ptr, "| @media %s%03lx",
      | ~~~~^
      | |
      | long unsigned int
      | %03llx
  135 | s->media->negate_type ? "not " : "",
  136 | s->media->type);
      | ~~~~~~~~~~~~~~
      | |
      | uint64_t {aka long long unsigned int}
In file included from test/parse2-auto.c:12:
test/dump.h: In function ‘dump_rule_media’:
test/dump.h:134:45: error: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Werror=format=]
  134 | ptr += sprintf(ptr, "| @media %s%03lx",
      | ~~~~^
      | |
      | long unsigned int
      | %03llx
  135 | s->media->negate_type ? "not " : "",
  136 | s->media->type);
      | ~~~~~~~~~~~~~~
      | |
      | uint64_t {aka long long unsigned int}
 COMPILE: test/select.c
    LINK: build-i686-unknown-linux-gnu-i686-unknown-linux-gnu-release-lib-shared/test_lex
    LINK: build-i686-unknown-linux-gnu-i686-unknown-linux-gnu-release-lib-shared/test_parse
    LINK: build-i686-unknown-linux-gnu-i686-unknown-linux-gnu-release-lib-shared/test_csdetect
    LINK: build-i686-unknown-linux-gnu-i686-unknown-linux-gnu-release-lib-shared/test_number
    LINK: build-i686-unknown-linux-gnu-i686-unknown-linux-gnu-release-lib-shared/test_lex-auto
    LINK: build-i686-unknown-linux-gnu-i686-unknown-linux-gnu-release-lib-shared/test_parse-auto
cc1: all warnings being treated as errors
```

The format specifier `%lx` does not match the `uint64_t` declaration on 32-bit systems, where `long int` is not 64 bits wide.

Anyhow, the following patch appears to fix the issue:

```
--- a/test/dump.h
+++ b/test/dump.h
@@ -131,7 +131,7 @@ void dump_rule_media(css_rule_media *s, char **buf, size_t *buflen)
        char *ptr = *buf;
        css_rule *rule;
 
- ptr += sprintf(ptr, "| @media %s%03lx",
+ ptr += sprintf(ptr, "| @media %s%03" PRIx64,
                        s->media->negate_type ? "not " : "",
                        s->media->type);
```

since the <inttypes.h> header is already in use.
TagsNo tags attached.
Attached Files

Notes
(0002448)
Vincent Sanders   
2024-05-25 11:14   
Thanks for the report, i have verified the issue and your fix. the fix has been committed to the source repository
 https://git.netsurf-browser.org/libcss.git/commit/?id=5dc01f53de94f81a911e33cb257631b9412c0d6f

Issue History
2024-03-09 04:21Richard BauerNew Issue
2024-05-25 11:14Vincent SandersAssigned To => Vincent Sanders
2024-05-25 11:14Vincent SandersStatusnew => resolved
2024-05-25 11:14Vincent SandersResolutionopen => fixed
2024-05-25 11:14Vincent SandersDescription Updatedbug_revision_view_page.php?rev_id=2201#r2201
2024-05-25 11:14Vincent SandersNote Added: 0002448