2024-11-21 16:14 UTC

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0002870LibCSSLibCSSpublic2024-05-25 11:14
ReporterRichard Bauer 
Assigned ToVincent Sanders 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
Platformi686-linuxOSGNU GuixOS Version
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.
Fixed in CI build #
Reported in CI build #
Attached Files

-Relationships
+Relationships

-Notes
Vincent Sanders

~0002448

Vincent Sanders (administrator)

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
+Notes

-Issue History
Date Modified Username Field Change
2024-03-09 04:21 Richard Bauer New Issue
2024-05-25 11:14 Vincent Sanders Assigned To => Vincent Sanders
2024-05-25 11:14 Vincent Sanders Status new => resolved
2024-05-25 11:14 Vincent Sanders Resolution open => fixed
2024-05-25 11:14 Vincent Sanders Description Updated View Revisions
2024-05-25 11:14 Vincent Sanders Note Added: 0002448
+Issue History