Skip to content

Commit cf2ccf2

Browse files
authored
Merge pull request #47 from KJTsanaktsidis/ktsanaktsidis/fix_function_pointer_errors
Make Syck compile with -Werror=incompatible-function-pointer-types
2 parents 0b94068 + ac0d6e6 commit cf2ccf2

4 files changed

Lines changed: 38 additions & 14 deletions

File tree

.github/workflows/test.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ jobs:
1616
matrix:
1717
ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
1818
os: [ubuntu-latest, macos-latest]
19+
exclude:
20+
- { os: macos-latest, ruby: '2.4' }
21+
- { os: macos-latest, ruby: '2.5' }
22+
include:
23+
- { os: macos-13, ruby: '2.4' }
24+
- { os: macos-13, ruby: '2.5' }
1925
runs-on: ${{ matrix.os }}
2026
steps:
2127
- uses: actions/checkout@v4

ext/syck/emitter.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,10 @@ syck_new_emitter(void)
138138
}
139139

140140
int
141-
syck_st_free_anchors( char *key, char *name, char *arg )
141+
syck_st_free_anchors( st_data_t key, st_data_t name, st_data_t arg )
142142
{
143-
S_FREE( name );
143+
char *name_as_ptr = (char *)name;
144+
S_FREE( name_as_ptr );
144145
return ST_CONTINUE;
145146
}
146147

ext/syck/rubyext.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ mktime_do(VALUE varg)
322322
}
323323

324324
VALUE
325-
mktime_r(VALUE varg)
325+
mktime_r(VALUE varg, VALUE errinfo)
326326
{
327327
struct mktime_arg *arg = (struct mktime_arg *)varg;
328328

@@ -351,7 +351,13 @@ rb_syck_mktime(const char *str, long len)
351351
* (see http://www.yaml.org/type/merge/)
352352
*/
353353
VALUE
354-
syck_merge_i(VALUE entry, VALUE hsh )
354+
syck_merge_i(
355+
#ifdef RB_BLOCK_CALL_FUNC_ARGLIST
356+
RB_BLOCK_CALL_FUNC_ARGLIST(entry, hsh)
357+
#else
358+
VALUE entry, VALUE hsh
359+
#endif
360+
)
355361
{
356362
VALUE tmp;
357363
if ( !NIL_P(tmp = rb_check_convert_type(entry, T_HASH, "Hash", "to_hash")) )
@@ -733,9 +739,9 @@ syck_set_model(VALUE p, VALUE input, VALUE model)
733739
}
734740

735741
static int
736-
syck_st_mark_nodes( char *key, SyckNode *n, char *arg )
742+
syck_st_mark_nodes( st_data_t key, st_data_t n, st_data_t arg )
737743
{
738-
if ( n != (void *)1 ) syck_node_mark( n );
744+
if ( n != 1 ) syck_node_mark( (SyckNode *)n );
739745
return ST_CONTINUE;
740746
}
741747

@@ -1042,7 +1048,13 @@ syck_resolver_node_import(VALUE self, VALUE node)
10421048
* Set instance variables
10431049
*/
10441050
VALUE
1045-
syck_set_ivars(VALUE vars, VALUE obj)
1051+
syck_set_ivars(
1052+
#ifdef RB_BLOCK_CALL_FUNC_ARGLIST
1053+
RB_BLOCK_CALL_FUNC_ARGLIST(vars, obj)
1054+
#else
1055+
VALUE vars, VALUE obj
1056+
#endif
1057+
)
10461058
{
10471059
VALUE ivname = rb_ary_entry( vars, 0 );
10481060
char *ivn;

ext/syck/syck.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,14 @@ syck_lookup_sym( SyckParser *p, SYMID id, void **datap )
201201
}
202202

203203
int
204-
syck_st_free_nodes( char *key, SyckNode *n, char *arg )
205-
{
206-
if ( n != (void *)1 ) syck_free_node( n );
207-
n = NULL;
204+
syck_st_free_nodes( st_data_t key, st_data_t n, st_data_t arg )
205+
{
206+
if ( n != 1 ) syck_free_node( (SyckNode *)n );
207+
/* Previously, this codde declared the `n` parameter as `SyckNode *`, and this
208+
* code said `n = NULL`. That's obviously a no-op, and this code _probably_ should
209+
* have said `*n = NULL`. However I'm terrified of actually changing Syck's behaviour
210+
* at this juncture, so I'll just adjust the type of the assignment to 0 from NULL. */
211+
n = 0;
208212
return ST_CONTINUE;
209213
}
210214

@@ -238,10 +242,11 @@ typedef struct {
238242
} bytestring_t;
239243

240244
int
241-
syck_st_free_syms( void *key, bytestring_t *sav, void *dummy )
245+
syck_st_free_syms( st_data_t key, st_data_t sav, st_data_t dummy )
242246
{
243-
S_FREE(sav->buffer);
244-
S_FREE(sav);
247+
bytestring_t *sav_ptr = (bytestring_t *)sav;
248+
S_FREE(sav_ptr->buffer);
249+
S_FREE(sav_ptr);
245250
return ST_CONTINUE;
246251
}
247252

0 commit comments

Comments
 (0)