Skip to content

Commit

Permalink
[flang1] Fix -Wcast-function-type-mismatch warnings; NFC (4/4)
Browse files Browse the repository at this point in the history
This patch fixes the type declaration for file I/O helpers to match
those of fread and rwrite.
  • Loading branch information
bryanpkc committed Oct 7, 2024
1 parent b03efc2 commit 1d69d8d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
22 changes: 11 additions & 11 deletions tools/flang1/flang1exe/semutil2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -13906,15 +13906,15 @@ 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;
state_still_pass_one = 0;
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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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 */

/*
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand Down
7 changes: 3 additions & 4 deletions tools/flang1/flang1exe/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 */
Expand Down

0 comments on commit 1d69d8d

Please sign in to comment.