From b75122b3ba743fb2ed943a78034aa4c0075b2d24 Mon Sep 17 00:00:00 2001 From: Bryan Chan Date: Tue, 1 Oct 2024 20:31:54 -0400 Subject: [PATCH] [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. --- tools/flang1/flang1exe/semutil2.c | 22 +++++++++++----------- tools/flang1/flang1exe/state.h | 7 +++---- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/tools/flang1/flang1exe/semutil2.c b/tools/flang1/flang1exe/semutil2.c index 5328ac593c5..abebe86e878 100644 --- a/tools/flang1/flang1exe/semutil2.c +++ b/tools/flang1/flang1exe/semutil2.c @@ -13799,7 +13799,7 @@ save_host_state(int wherefrom) } } } - rw_host_state(wherefrom, (int (*)())fwrite, state_file); + rw_host_state(wherefrom, fwrite, state_file); saved_symavl = stb.stg_avail; saved_astavl = astb.stg_avail; saved_dtyavl = stb.dt.stg_avail; @@ -13906,7 +13906,7 @@ restore_host_state(int whichpass) if (whichpass == 2) { fseek(state_file, 0L, 0); - rw_host_state(0x13, (int (*)())fread, state_file); + rw_host_state(0x13, fread, state_file); /*astb.firstuast = astb.stg_avail;*/ /* ### don't reset firstusym for main program */ stb.firstusym = stb.stg_avail; @@ -13914,7 +13914,7 @@ restore_host_state(int whichpass) fix_symtab(); } else if (whichpass == 4) { /* for ipa import */ fseek(state_file, 0L, 0); - rw_host_state(0x2, (int (*)())fread, state_file); + rw_host_state(0x2, fread, state_file); /*astb.firstuast = astb.stg_avail;*/ /* ### don't reset firstusym for main program */ stb.firstusym = stb.stg_avail; @@ -13993,7 +13993,7 @@ restore_host_state(int whichpass) saved_labels[saved_labels_avail] = ';'; fseek(state_file, 0L, 0); - rw_host_state(0x3, (int (*)())fread, state_file); + rw_host_state(0x3, fread, state_file); /*astb.firstuast = astb.stg_avail;*/ fseek(state_append_file, state_file_position, 0); @@ -14124,13 +14124,13 @@ save_module_state1() if (modstate_file == NULL) errfatal(5); } - rw_host_state(0x1, (int (*)())fwrite, modstate_file); + rw_host_state(0x1, fwrite, modstate_file); } /* save_module_state1 */ void save_module_state2() { - rw_host_state(0x16, (int (*)())fwrite, modstate_file); + rw_host_state(0x16, fwrite, modstate_file); modsaved_symavl = stb.stg_avail; modsaved_astavl = astb.stg_avail; modsaved_dtyavl = stb.dt.stg_avail; @@ -14151,14 +14151,14 @@ save_imported_modules_state() if (modsave_file == NULL) errfatal(5); } - rw_host_state(0x20, (int (*)())fwrite, modsave_file); + rw_host_state(0x20, fwrite, modsave_file); } /* save_imported_modules_state */ void restore_imported_modules_state() { fseek(modsave_file, 0L, 0); - rw_host_state(0x20, (int (*)())fread, modsave_file); + rw_host_state(0x20, fread, modsave_file); } /* restore_imported_modules_state */ /* @@ -14193,7 +14193,7 @@ restore_module_state() errfatal(5); /* First, read the binary-saved information */ fseek(modstate_file, 0L, 0); - rw_host_state(0x17, (int (*)())fread, modstate_file); + rw_host_state(0x17, fread, modstate_file); /* for TPR 1654, if we need to set NEEDMOD for internal * subprograms, this is the place to set it * NEEDMODP( stb.curr_scope, 1 ); @@ -14221,7 +14221,7 @@ restore_module_state() mod_clear_init = 0; /* Lastly, rewrite the module state file */ fseek(modstate_file, 0L, 0); - rw_host_state(0x17, (int (*)())fwrite, modstate_file); + rw_host_state(0x17, fwrite, modstate_file); modsaved_symavl = stb.stg_avail; modsaved_astavl = astb.stg_avail; modsaved_dtyavl = stb.dt.stg_avail; @@ -14239,7 +14239,7 @@ reset_module_state() interr("no module state file to restore", 0, 4); if (sem.which_pass == 1) { fseek(modstate_file, 0L, 0); - rw_host_state(0x17, (int (*)())fread, modstate_file); + rw_host_state(0x17, fread, modstate_file); } else { /* export the module-contained subprogram */ if (!modstate_append_file) { diff --git a/tools/flang1/flang1exe/state.h b/tools/flang1/flang1exe/state.h index a72fa822e42..2dbec63ba9a 100644 --- a/tools/flang1/flang1exe/state.h +++ b/tools/flang1/flang1exe/state.h @@ -32,9 +32,9 @@ * this declares the proper names for the rw_routine and file * used in the RW_ macros */ -#define RW_ROUTINE int (*p_rw)(void *, size_t, size_t, FILE *) +#define RW_ROUTINE size_t (*p_rw)(void *, size_t, size_t, FILE *) #define RW_FILE FILE *fd -#define RW_ROUTINE_TYPE int (*)(void *, size_t, size_t, FILE *) +#define RW_ROUTINE_TYPE size_t (*)(void *, size_t, size_t, FILE *) /* * sometimes special action is taken on read or write. @@ -47,8 +47,7 @@ extern void rw_dpmout_state(RW_ROUTINE, RW_FILE); extern void rw_semant_state(RW_ROUTINE, RW_FILE); /* semfin.c */ extern void rw_gnr_state(RW_ROUTINE, RW_FILE); /* semgnr.c */ extern void rw_sym_state(RW_ROUTINE, RW_FILE); /* symtab.c */ -extern void rw_dtype_state(int (*p_rw)(void *, size_t, size_t, FILE *), - FILE *fd); /* dtypeutl.c */ +extern void rw_dtype_state(RW_ROUTINE, RW_FILE); /* dtypeutl.c */ extern void rw_ast_state(RW_ROUTINE, RW_FILE); /* ast.c */ extern void rw_dinit_state(RW_ROUTINE, RW_FILE); /* dinit.c */ extern void rw_import_state(RW_ROUTINE, RW_FILE); /* interf.c */