File: 0006-Fix-compilation-error-due-to-very-old-style-C-code-C.patch

package info (click to toggle)
xfireworks 1.3-16
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,036 kB
  • sloc: ansic: 6,896; makefile: 383; sh: 40
file content (131 lines) | stat: -rw-r--r-- 5,522 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
From: Yukiharu YABUKI <yyabuki@debian.org>
Date: Mon, 15 Sep 2025 22:43:22 +0900
Subject: Fix compilation error due to very old style C code (Closes:
 #1114447)

The build failed due to multiple `[-Wincompatible-pointer-types]` errors
when passing destructor callback functions to `ObjList` manipulation
routines.

Functions like `ObjList_InsertObjToStart` and `ObjList_InsertObjToEnd`
were declared in `Obj.h` with an old-style C function pointer syntax:
`Obj (*destructor)()`. This style implicitly informs the compiler that
the function takes no arguments, leading it to interpret the signature
as `void * (*)(void)`.

However, the actual destructor functions provided (e.g.,
`ColorGCInstance_Destroy`) are defined and intended to accept an `Obj`
argument, which is typically a `void *`, matching a `void * (*)(void *)`
signature. This mismatch between the declared and actual function
pointer types caused the compiler errors.

To resolve this, update the function pointer declarations in `Obj.h` to
explicitly specify that the destructor takes an `Obj` argument. This
changes the signature from `Obj (*destructor)()` to `Obj (*destructor)(Obj)`,
aligning the declaration with the expected and provided function type
and resolving the incompatible pointer type errors.

Example error:

    ColorGC.c:160:30: error: passing argument 3 of 'ObjList_InsertObjToStart' from incompatible pointer type [-Wincompatible-pointer-types]
     160 |                              (ObjDestructor)ColorGCInstance_Destroy);
         |                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Obj.h:41:44: note: expected 'void * (*)(void)' but argument is of type 'void * (*)(void *)'
     41 |                                      Obj (*destructor)());
        |                                      ~~~~~~^~~~~~~~~~~~~

Update function definitions in Obj.c to match
the `destructor` function pointer signature declared in Obj.h. The definitions
used an old-style declaration `Obj (*destructor)()`, which implied `void`
parameters. This conflicted with the `Obj (*destructor)(Obj)` signature
specified in the header file.

This change resolves several `conflicting types` errors for the
`ObjList_InsertObjToPrev`, `ObjList_InsertObjToNext`,
`ObjList_InsertObjToStart`, and `ObjList_InsertObjToEnd` functions,
and an `incompatible-pointer-types` error for `ObjListData_Create`,
ensuring type consistency across declarations and definitions.

Errors fixed:
    Obj.c:21:25: error: assignment to 'void * (*)(void *)' from incompatible
                         pointer type 'void * (*)(void)'
    Obj.c:121:13: error: conflicting types for 'ObjList_InsertObjToPrev'
    Obj.c:141:13: error: conflicting types for 'ObjList_InsertObjToNext'
    Obj.c:161:13: error: conflicting types for 'ObjList_InsertObjToStart'
    Obj.c:169:13: error: conflicting types for 'ObjList_InsertObjToEnd'
---
 Obj.c | 10 +++++-----
 Obj.h |  8 ++++----
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/Obj.c b/Obj.c
index a8cc01e..39fc9d9 100644
--- a/Obj.c
+++ b/Obj.c
@@ -11,7 +11,7 @@
 /* ObjListData                                                       */
 /*****************************************************************************/
 
-static ObjListData ObjListData_Create(Obj obj, Obj (*destructor)())
+static ObjListData ObjListData_Create(Obj obj, Obj (*destructor)(Obj))
 {
   ObjListData list_data;
 
@@ -119,7 +119,7 @@ int ObjList_IsEnd(ObjList list, ObjListData data)
 }
 
 ObjListData ObjList_InsertObjToPrev(ObjList list, ObjListData current,
-				    Obj obj, Obj (*destructor)())
+				    Obj obj, Obj (*destructor)(Obj))
 {
   ObjListData data;
 
@@ -139,7 +139,7 @@ ObjListData ObjList_InsertObjToPrev(ObjList list, ObjListData current,
 }
 
 ObjListData ObjList_InsertObjToNext(ObjList list, ObjListData current,
-				    Obj obj, Obj (*destructor)())
+				    Obj obj, Obj (*destructor)(Obj))
 {
   ObjListData data;
 
@@ -159,7 +159,7 @@ ObjListData ObjList_InsertObjToNext(ObjList list, ObjListData current,
 }
 
 ObjListData ObjList_InsertObjToStart(ObjList list, Obj obj,
-				     Obj (*destructor)())
+				     Obj (*destructor)(Obj))
 {
   ObjListData current;
   current = ObjList_GetStart(list);
@@ -167,7 +167,7 @@ ObjListData ObjList_InsertObjToStart(ObjList list, Obj obj,
 }
 
 ObjListData ObjList_InsertObjToEnd(ObjList list, Obj obj,
-				   Obj (*destructor)())
+				   Obj (*destructor)(Obj))
 {
   ObjListData current;
   current = ObjList_GetEnd(list);
diff --git a/Obj.h b/Obj.h
index 223b348..ba73fc4 100644
--- a/Obj.h
+++ b/Obj.h
@@ -34,13 +34,13 @@ int ObjList_IsEndEdge(ObjList list, ObjListData data);
 int ObjList_IsStart(ObjList list, ObjListData data);
 int ObjList_IsEnd(ObjList list, ObjListData data);
 ObjListData ObjList_InsertObjToPrev(ObjList list, ObjListData current,
-				    Obj obj, Obj (*destructor)());
+				    Obj obj, Obj (*destructor)(Obj));
 ObjListData ObjList_InsertObjToNext(ObjList list, ObjListData current,
-				    Obj obj, Obj (*destructor)());
+				    Obj obj, Obj (*destructor)(Obj));
 ObjListData ObjList_InsertObjToStart(ObjList list, Obj obj,
-				     Obj (*destructor)());
+				     Obj (*destructor)(Obj));
 ObjListData ObjList_InsertObjToEnd(ObjList list, Obj obj,
-				   Obj (*destructor)());
+				   Obj (*destructor)(Obj));
 ObjListData ObjList_DeleteObjToPrev(ObjList list, ObjListData current);
 ObjListData ObjList_DeleteObjToNext(ObjList list, ObjListData current);
 ObjListData ObjList_DeleteObjFromStart(ObjList list);