Skip to content

Commit 1d69d8d

Browse files
committed
[flang1] Fix -Wcast-function-type-mismatch warnings; NFC (4/4)
This patch fixes the type declaration for file I/O helpers to match those of fread and rwrite.
1 parent b03efc2 commit 1d69d8d

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

tools/flang1/flang1exe/semutil2.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13799,7 +13799,7 @@ save_host_state(int wherefrom)
1379913799
}
1380013800
}
1380113801
}
13802-
rw_host_state(wherefrom, (int (*)())fwrite, state_file);
13802+
rw_host_state(wherefrom, fwrite, state_file);
1380313803
saved_symavl = stb.stg_avail;
1380413804
saved_astavl = astb.stg_avail;
1380513805
saved_dtyavl = stb.dt.stg_avail;
@@ -13906,15 +13906,15 @@ restore_host_state(int whichpass)
1390613906

1390713907
if (whichpass == 2) {
1390813908
fseek(state_file, 0L, 0);
13909-
rw_host_state(0x13, (int (*)())fread, state_file);
13909+
rw_host_state(0x13, fread, state_file);
1391013910
/*astb.firstuast = astb.stg_avail;*/
1391113911
/* ### don't reset firstusym for main program */
1391213912
stb.firstusym = stb.stg_avail;
1391313913
state_still_pass_one = 0;
1391413914
fix_symtab();
1391513915
} else if (whichpass == 4) { /* for ipa import */
1391613916
fseek(state_file, 0L, 0);
13917-
rw_host_state(0x2, (int (*)())fread, state_file);
13917+
rw_host_state(0x2, fread, state_file);
1391813918
/*astb.firstuast = astb.stg_avail;*/
1391913919
/* ### don't reset firstusym for main program */
1392013920
stb.firstusym = stb.stg_avail;
@@ -13993,7 +13993,7 @@ restore_host_state(int whichpass)
1399313993
saved_labels[saved_labels_avail] = ';';
1399413994

1399513995
fseek(state_file, 0L, 0);
13996-
rw_host_state(0x3, (int (*)())fread, state_file);
13996+
rw_host_state(0x3, fread, state_file);
1399713997
/*astb.firstuast = astb.stg_avail;*/
1399813998

1399913999
fseek(state_append_file, state_file_position, 0);
@@ -14124,13 +14124,13 @@ save_module_state1()
1412414124
if (modstate_file == NULL)
1412514125
errfatal(5);
1412614126
}
14127-
rw_host_state(0x1, (int (*)())fwrite, modstate_file);
14127+
rw_host_state(0x1, fwrite, modstate_file);
1412814128
} /* save_module_state1 */
1412914129

1413014130
void
1413114131
save_module_state2()
1413214132
{
14133-
rw_host_state(0x16, (int (*)())fwrite, modstate_file);
14133+
rw_host_state(0x16, fwrite, modstate_file);
1413414134
modsaved_symavl = stb.stg_avail;
1413514135
modsaved_astavl = astb.stg_avail;
1413614136
modsaved_dtyavl = stb.dt.stg_avail;
@@ -14151,14 +14151,14 @@ save_imported_modules_state()
1415114151
if (modsave_file == NULL)
1415214152
errfatal(5);
1415314153
}
14154-
rw_host_state(0x20, (int (*)())fwrite, modsave_file);
14154+
rw_host_state(0x20, fwrite, modsave_file);
1415514155
} /* save_imported_modules_state */
1415614156

1415714157
void
1415814158
restore_imported_modules_state()
1415914159
{
1416014160
fseek(modsave_file, 0L, 0);
14161-
rw_host_state(0x20, (int (*)())fread, modsave_file);
14161+
rw_host_state(0x20, fread, modsave_file);
1416214162
} /* restore_imported_modules_state */
1416314163

1416414164
/*
@@ -14193,7 +14193,7 @@ restore_module_state()
1419314193
errfatal(5);
1419414194
/* First, read the binary-saved information */
1419514195
fseek(modstate_file, 0L, 0);
14196-
rw_host_state(0x17, (int (*)())fread, modstate_file);
14196+
rw_host_state(0x17, fread, modstate_file);
1419714197
/* for TPR 1654, if we need to set NEEDMOD for internal
1419814198
* subprograms, this is the place to set it
1419914199
* NEEDMODP( stb.curr_scope, 1 );
@@ -14221,7 +14221,7 @@ restore_module_state()
1422114221
mod_clear_init = 0;
1422214222
/* Lastly, rewrite the module state file */
1422314223
fseek(modstate_file, 0L, 0);
14224-
rw_host_state(0x17, (int (*)())fwrite, modstate_file);
14224+
rw_host_state(0x17, fwrite, modstate_file);
1422514225
modsaved_symavl = stb.stg_avail;
1422614226
modsaved_astavl = astb.stg_avail;
1422714227
modsaved_dtyavl = stb.dt.stg_avail;
@@ -14239,7 +14239,7 @@ reset_module_state()
1423914239
interr("no module state file to restore", 0, 4);
1424014240
if (sem.which_pass == 1) {
1424114241
fseek(modstate_file, 0L, 0);
14242-
rw_host_state(0x17, (int (*)())fread, modstate_file);
14242+
rw_host_state(0x17, fread, modstate_file);
1424314243
} else {
1424414244
/* export the module-contained subprogram */
1424514245
if (!modstate_append_file) {

tools/flang1/flang1exe/state.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
* this declares the proper names for the rw_routine and file
3333
* used in the RW_ macros
3434
*/
35-
#define RW_ROUTINE int (*p_rw)(void *, size_t, size_t, FILE *)
35+
#define RW_ROUTINE size_t (*p_rw)(void *, size_t, size_t, FILE *)
3636
#define RW_FILE FILE *fd
37-
#define RW_ROUTINE_TYPE int (*)(void *, size_t, size_t, FILE *)
37+
#define RW_ROUTINE_TYPE size_t (*)(void *, size_t, size_t, FILE *)
3838

3939
/*
4040
* sometimes special action is taken on read or write.
@@ -47,8 +47,7 @@ extern void rw_dpmout_state(RW_ROUTINE, RW_FILE);
4747
extern void rw_semant_state(RW_ROUTINE, RW_FILE); /* semfin.c */
4848
extern void rw_gnr_state(RW_ROUTINE, RW_FILE); /* semgnr.c */
4949
extern void rw_sym_state(RW_ROUTINE, RW_FILE); /* symtab.c */
50-
extern void rw_dtype_state(int (*p_rw)(void *, size_t, size_t, FILE *),
51-
FILE *fd); /* dtypeutl.c */
50+
extern void rw_dtype_state(RW_ROUTINE, RW_FILE); /* dtypeutl.c */
5251
extern void rw_ast_state(RW_ROUTINE, RW_FILE); /* ast.c */
5352
extern void rw_dinit_state(RW_ROUTINE, RW_FILE); /* dinit.c */
5453
extern void rw_import_state(RW_ROUTINE, RW_FILE); /* interf.c */

0 commit comments

Comments
 (0)