2024-11-23 08:01 UTC

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0002877LibDOM[All Projects] Generalpublic2024-06-14 02:31
ReporterBruce Benson 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusnewResolutionopen 
PlatformGTKOSLinuxOS VersionFedora 40
Summary0002877: patches for v3.11 libdom, fixes ns-make-libs install stopped by compiler warning
Description(note: I am not the Fedora package maintainer, Fedora is building on 3.9 apparently)

quick build steps on Fedora 40 fail on compile warning.


make: Entering directory '/home/bbenson/dev-netsurf/workspace/libdom'
 COMPILE: bindings/xml/expat_xmlparser.c
 COMPILE: src/core/node.c
 COMPILE: src/html/html_document.c
bindings/xml/expat_xmlparser.c: In function ‘dom_xml_parser_create’:
bindings/xml/expat_xmlparser.c:487:31: error: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
  487 | parser = calloc(sizeof(*parser), 1);
      | ^
bindings/xml/expat_xmlparser.c:487:31: note: earlier argument should specify number of elements, later size of each element
cc1: all warnings being treated as errors
make: *** [/home/bbenson/dev-netsurf/workspace/inst-x86_64-redhat-linux/share/netsurf-buildsystem/makefiles/Makefile.top:603: build-x86_64-redhat-linux-x86_64-redhat-linux-release-lib-static/bindings_xml_expat_xmlparser.o] Error 1
make: *** Waiting for unfinished jobs....
src/core/node.c: In function ‘_dom_event_targets_expand’:
src/core/node.c:2382:34: error: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
 2382 | t = calloc(sizeof(*t), size);
      | ^
src/core/node.c:2382:34: note: earlier argument should specify number of elements, later size of each element
cc1: all warnings being treated as errors
make: *** [/home/bbenson/dev-netsurf/workspace/inst-x86_64-redhat-linux/share/netsurf-buildsystem/makefiles/Makefile.top:603: build-x86_64-redhat-linux-x86_64-redhat-linux-release-lib-static/src_core_node.o] Error 1
src/html/html_document.c: In function ‘_dom_html_document_initialise’:
src/html/html_document.c:137:39: error: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
  137 | doc->memoised = calloc(sizeof(dom_string *), hds_COUNT);
      | ^~~~~~~~~~
src/html/html_document.c:137:39: note: earlier argument should specify number of elements, later size of each element
src/html/html_document.c:142:39: error: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
  142 | doc->elements = calloc(sizeof(dom_string *),
      | ^~~~~~~~~~
src/html/html_document.c:142:39: note: earlier argument should specify number of elements, later size of each element
cc1: all warnings being treated as errors
make: *** [/home/bbenson/dev-netsurf/workspace/inst-x86_64-redhat-linux/share/netsurf-buildsystem/makefiles/Makefile.top:603: build-x86_64-redhat-linux-x86_64-redhat-linux-release-lib-static/src_html_html_document.o] Error 1
make: Leaving directory '/home/bbenson/dev-netsurf/workspace/libdom'
Steps To ReproduceAttempted to git source and compile on Fedora 40 x86_64 using quick build, for either to either GTK or qt6.
During ns-pull-install (ns-make-libs compiler part), gcc appears to stop compilation due to warnings treated as errors ("-Werror=calloc-transposed-args"). Possibly due to newer compiler defaults in Fedora 40.

Applied changes listed in patch below, compile completed successfully, and app appears to work fine.

I'm not saying these patches are required. You all may want to change compiler options instead or may have other considerations. I enjoy the browser project and wanted to help.
Thanks!!
Additional Information~/dev-netsurf-compiled/workspace/libdom $ git diff
diff --git a/bindings/xml/expat_xmlparser.c b/bindings/xml/expat_xmlparser.c
index a63ccf1..ba5b4e7 100644
--- a/bindings/xml/expat_xmlparser.c
+++ b/bindings/xml/expat_xmlparser.c
@@ -484,7 +484,7 @@ dom_xml_parser_create(const char *enc, const char *int_enc,
 
        UNUSED(int_enc);
 
- parser = calloc(sizeof(*parser), 1);
+ parser = calloc(1, sizeof(*parser));
        if (parser == NULL) {
                msg(DOM_MSG_CRITICAL, mctx, "No memory for parser");
                return NULL;
diff --git a/src/core/node.c b/src/core/node.c
diff --git a/bindings/xml/expat_xmlparser.c b/bindings/xml/expat_xmlparser.c
index a63ccf1..ba5b4e7 100644
--- a/bindings/xml/expat_xmlparser.c
+++ b/bindings/xml/expat_xmlparser.c
@@ -484,7 +484,7 @@ dom_xml_parser_create(const char *enc, const char *int_enc,
 
        UNUSED(int_enc);
 
- parser = calloc(sizeof(*parser), 1);
+ parser = calloc(1, sizeof(*parser));
        if (parser == NULL) {
                msg(DOM_MSG_CRITICAL, mctx, "No memory for parser");
                return NULL;
diff --git a/src/core/node.c b/src/core/node.c
index da179c3..9eabd2f 100644
--- a/src/core/node.c
+++ b/src/core/node.c
@@ -2379,7 +2379,7 @@ static inline dom_exception _dom_event_targets_expand(
        if (t == NULL) {
                /* Create the event target list */
                size = 64;
- t = calloc(sizeof(*t), size);
+ t = calloc(size, sizeof(*t));
                if (t == NULL) {
                        return DOM_NO_MEM_ERR;
                }
diff --git a/src/html/html_document.c b/src/html/html_document.c
index cf3c25d..7ba91aa 100644
--- a/src/html/html_document.c
+++ b/src/html/html_document.c
@@ -134,13 +134,13 @@ dom_exception _dom_html_document_initialise(dom_html_document *doc,
        doc->cookie = NULL;
        doc->body = NULL;
 
- doc->memoised = calloc(sizeof(dom_string *), hds_COUNT);
+ doc->memoised = calloc(hds_COUNT, sizeof(dom_string *));
        if (doc->memoised == NULL) {
                error = DOM_NO_MEM_ERR;
                goto out;
        }
- doc->elements = calloc(sizeof(dom_string *),
- DOM_HTML_ELEMENT_TYPE__COUNT);
+ doc->elements = calloc(DOM_HTML_ELEMENT_TYPE__COUNT,
+ sizeof(dom_string *));
        if (doc->elements == NULL) {
                error = DOM_NO_MEM_ERR;
                goto out;
TagsNo tags attached.
Fixed in CI build #
Reported in CI build #
Attached Files

-Relationships
+Relationships

-Notes
There are no notes attached to this issue.
+Notes

-Issue History
Date Modified Username Field Change
2024-06-14 02:31 Bruce Benson New Issue
+Issue History