Giter Site home page Giter Site logo

Compilation failure with GCC 14 about ftl HOT 7 CLOSED

mbooth101 avatar mbooth101 commented on July 17, 2024
Compilation failure with GCC 14

from ftl.

Comments (7)

mbooth101 avatar mbooth101 commented on July 17, 2024

I am locally appling a patch like this:

From a6b6d2d7cfd9774220ccd00d031e2f699afd3d29 Mon Sep 17 00:00:00 2001
From: Mat Booth <[email protected]>
Date: Sun, 17 Mar 2024 15:32:40 +0000
Subject: [PATCH] Fix compilation errors caused by GCC 14

---
 .../src/CMakeLists.txt                              | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/FTL-abcbcc58f5a63c21a11a4af2f0d5a664aa11ecfa/src/CMakeLists.txt b/FTL-abcbcc58f5a63c21a11a4af2f0d5a664aa11ecfa/src/CMakeLists.txt
index 185ba5d..f689760 100644
--- a/FTL-abcbcc58f5a63c21a11a4af2f0d5a664aa11ecfa/src/CMakeLists.txt
+++ b/FTL-abcbcc58f5a63c21a11a4af2f0d5a664aa11ecfa/src/CMakeLists.txt
@@ -155,11 +155,22 @@ else()
 set(EXTRAWARN_GCC13 "")
 endif()
 
+# Extra warnings flags available only in GCC 14 and higher
+# In GCC 14, -Wextra implies -Wcalloc-transposed-args however, there is
+# nothing wrong with the calls to calloc that it detects, so disable
+# that warning here
+if(CMAKE_C_COMPILER_VERSION VERSION_EQUAL 14 OR CMAKE_C_COMPILER_VERSION VERSION_GREATER 14)
+set(EXTRAWARN_GCC14 "-Wno-calloc-transposed-args")
+else()
+set(EXTRAWARN_GCC14 "")
+endif()
+
 set(EXTRAWARN "${EXTRAWARN_GCC6} \
                ${EXTRAWARN_GCC7} \
                ${EXTRAWARN_GCC8} \
                ${EXTRAWARN_GCC12} \
-               ${EXTRAWARN_GCC13}")
+               ${EXTRAWARN_GCC13} \
+               ${EXTRAWARN_GCC14}")
 
 # Remove extra spaces from EXTRAWARN
 string(REGEX REPLACE " +" " " EXTRAWARN "${EXTRAWARN}")
-- 
2.41.0

from ftl.

DL6ER avatar DL6ER commented on July 17, 2024

Thanks for your comments, I haven't tried building on such a recent GCC version myself. I'm actually torn about the solution you suggest - yes, sure, there isn't anything wrong with our code. The warning wants to ensure we are using calloc() as it was designed and that means the first argument is nmem and the second size. Even when it makes no functional difference, one could also argument that the "real" fix would be

-cap_user_header_t hdr = calloc(sizeof(*hdr), capsize);
+cap_user_header_t hdr = calloc(capsize, sizeof(*hdr));

What do you think? I'm always trying to try to comply with compiler warnings whenever possible (and meaningful). It seems meaningful here because (warning: rusty partially unreliable memory excerpt ahead!) I recall that calloc may be implemented in a way that ensures alignment matching the size parameter. So the order of the arguments can actually make a difference and the mere fact that someone did the work adding warning rules to GCC 14 (combined with that this has been accepted) tells me that there are good reasons to use the function as defined :-)

from ftl.

DL6ER avatar DL6ER commented on July 17, 2024

For reference: gcc-mirror/gcc@e7dd72a

from ftl.

mbooth101 avatar mbooth101 commented on July 17, 2024

I am happy to see it fixed in any manner you think is best -- I am not a GCC expert, nor am I a FTL expert -- but your fix may indeed be better if only because not disabling the warning would prevent more infractions from sneaking into the code base. :-)

from ftl.

DL6ER avatar DL6ER commented on July 17, 2024

You could test swapping the arguments locally to see if anything else comes up. As GCC 14 has not even been officially released, I'm a bit hesitant to invest time into creating/installing a full testing environment yet. We may simply wait for alpine:edge to eventually pick it up once finalized.

from ftl.

github-actions avatar github-actions commented on July 17, 2024

This issue is stale because it has been open 30 days with no activity. Please comment or update this issue or it will be closed in 5 days.

from ftl.

pralor-bot avatar pralor-bot commented on July 17, 2024

This issue has been mentioned on Pi-hole Userspace. There might be relevant details there:

https://discourse.pi-hole.net/t/certificate-domain-mismatch-warning-behind-reverse-proxy/70521/3

from ftl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.