tux4kids / t4kcommon

GNU General Public License v3.0
4 stars 11 forks source link

linebreak: Avoid implicit declaration of u8_mbtouc_unsafe function #16

Open fweimer-rh opened 1 year ago

fweimer-rh commented 1 year ago

GNULIB_UNISTR_U8_MBTOUC_UNSAFE tells the bundled unistr.h to provide a function prototype for u8_mbtouc_unsafe. This prevents build failures with future compilers which do not support implicit function declarations.

Upstream gnulib has split the linebreak module into multiple parts; it is hard to tell if it still has the same issue.

Related to:

https://fedoraproject.org/wiki/Changes/PortingToModernC https://fedoraproject.org/wiki/Toolchain/PortingToModernC

listout commented 9 months ago

@fweimer-rh Thanks for the patch.

Along with this fix, I found we also need a little bit more fixing to be able to build with GCC 14

Bug: https://bugs.gentoo.org/923789
From: Brahmajit Das <brahmajit.xyz@gmail.com>
Date: Fri, 9 Feb 2024 11:49:53 +0530
Subject: [PATCH 2/2] t4k_menu: Fix passing incompatible pointer type

First observed under Gentoo Linux with GCC 14, probably due to
mismatching types between child (struct _xmlAttr *) and node.children
(struct _xmlAttr *).

Resulting in build errors such as
t4k_menu.c:254:23: error: assignment to 'xmlAttr *' {aka 'struct _xmlAttr *'} from incompatible pointer type 'struct _xmlNode *' [-Wincompatible-pointer-types]
  254 |             for(child = node->children; child; child = child->next) {
      |                       ^
t4k_menu.c:256:62: error: passing argument 1 of 'menu_TranslateNode' from incompatible pointer type [-Wincompatible-pointer-types]
  256 |                     tnode->submenu[i++] = menu_TranslateNode(child);
      |                                                              ^~~~~
      |                                                              |
      |                                                              xmlAttr * {aka struct _xmlAttr *}

Please reffer Gentoo bug: https://bugs.gentoo.org/923789
Signed-off-by: Brahmajit Das <brahmajit.xyz@gmail.com>
--- a/src/t4k_menu.c
+++ b/src/t4k_menu.c
@@ -251,9 +251,10 @@ MenuNode *menu_TranslateNode(xmlNode *node) {
         /* Now add child nodes. */
         if(xmlStrcasecmp(node->name, "menu") == 0) {
             i = 0;
-            for(child = node->children; child; child = child->next) {
-                if(child->type == XML_ELEMENT_NODE) {
-                    tnode->submenu[i++] = menu_TranslateNode(child);
+            xmlNode *childNode = NULL;
+            for(childNode = node->children; childNode; childNode = childNode->next) {
+                if(childNode->type == XML_ELEMENT_NODE) {
+                    tnode->submenu[i++] = menu_TranslateNode(childNode);
                 }
             }
         }
@@ -443,7 +444,7 @@ int T4K_RunMenu(int index, bool return_choice, void (*draw_background)(), int (*
   int click_flag = 1;
   int using_scroll = 0;

-  internal_res_switch_handler(&T4K_PrerenderAll);
+  internal_res_switch_handler((ResSwitchCallback)&T4K_PrerenderAll);

   for(;;) /* one loop body execution for one menu page */
   {
-- 
2.43.0
listout commented 6 months ago

(humble ping)