Skip to content

Commit

Permalink
Fix missing statics and dead code identified with -Wmissing-declarati…
Browse files Browse the repository at this point in the history
…ons (#481)

Co-authored-by: David Gardner <[email protected]>
Co-authored-by: Cody Balos <[email protected]>
  • Loading branch information
3 people committed Jun 20, 2024
1 parent 77db644 commit cbbaca3
Show file tree
Hide file tree
Showing 14 changed files with 70 additions and 295 deletions.
17 changes: 17 additions & 0 deletions doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,23 @@ implementation, however some may be required based on the implementation's
:c:type:`SUNAdaptController_Type` (see Section :numref:`SUNAdaptController.Description.controllerTypes`). We
note these requirements below. Additionally, we note the behavior of the base SUNAdaptController methods when they perform an action other than only a successful return.
.. c:function:: void SUNAdaptController_DestroyEmpty(SUNAdaptController C)
This routine frees the generic ``SUNAdaptController`` object, under the
assumption that any implementation-specific data that was allocated within the
underlying content structure has already been freed. It will additionally test
whether the ops pointer is ``NULL``, and, if it is not, it will free it as
well.
:param C: the :c:type:`SUNAdaptController` object.
:return: :c:type:`SUNErrCode` indicating success or failure.
Usage:
.. code-block:: c
retval = SUNAdaptController_DestroyEmpty(C);
.. c:function:: SUNAdaptController_Type SUNAdaptController_GetType(SUNAdaptController C)
Returns the type identifier for the controller *C*. Returned values
Expand Down
4 changes: 2 additions & 2 deletions examples/arkode/C_serial/ark_damped_harmonic_symplectic.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ int main(int argc, char* argv[])
return 0;
}

sunrealtype omega(sunrealtype t) { return cos(t / SUN_RCONST(2.0)); }
static sunrealtype omega(sunrealtype t) { return cos(t / SUN_RCONST(2.0)); }

sunrealtype F(sunrealtype t) { return SUN_RCONST(0.018) * sin(t / PI); }
static sunrealtype F(sunrealtype t) { return SUN_RCONST(0.018) * sin(t / PI); }

sunrealtype Hamiltonian(N_Vector yvec, sunrealtype t)
{
Expand Down
6 changes: 3 additions & 3 deletions examples/arkode/C_serial/ark_harmonic_symplectic.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ typedef struct
sunrealtype dt;
} ProgramArgs;

void PrintHelp(void)
static void PrintHelp(void)
{
fprintf(stderr, "ark_harmonic_symplectic: an ARKODE example demonstrating "
"the SPRKStep time-stepping module solving a simple harmonic "
Expand All @@ -48,7 +48,7 @@ void PrintHelp(void)
/* clang-format on */
}

int ParseArgs(int argc, char* argv[], ProgramArgs* args)
static int ParseArgs(int argc, char* argv[], ProgramArgs* args)
{
int argi = 0;

Expand Down Expand Up @@ -110,7 +110,7 @@ int ParseArgs(int argc, char* argv[], ProgramArgs* args)
opt == 2 means function allocates memory so check if returned
NULL pointer
*/
int check_retval(void* returnvalue, const char* funcname, int opt)
static int check_retval(void* returnvalue, const char* funcname, int opt)
{
int* retval;

Expand Down
11 changes: 6 additions & 5 deletions examples/arkode/C_serial/ark_kepler.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ typedef struct
const char* method_name;
} ProgramArgs;

int ComputeConvergence(int num_dt, sunrealtype* orders,
sunrealtype expected_order, sunrealtype a11,
sunrealtype a12, sunrealtype a21, sunrealtype a22,
sunrealtype b1, sunrealtype b2, sunrealtype* ord_avg,
sunrealtype* ord_max, sunrealtype* ord_est)
static int ComputeConvergence(int num_dt, sunrealtype* orders,
sunrealtype expected_order, sunrealtype a11,
sunrealtype a12, sunrealtype a21, sunrealtype a22,
sunrealtype b1, sunrealtype b2,
sunrealtype* ord_avg, sunrealtype* ord_max,
sunrealtype* ord_est)
{
/* Compute/print overall estimated convergence rate */
int i = 0;
Expand Down
4 changes: 4 additions & 0 deletions include/sundials/sundials_adaptcontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ struct _generic_SUNAdaptController
SUNDIALS_EXPORT
SUNAdaptController SUNAdaptController_NewEmpty(SUNContext sunctx);

/* Function to free a generic SUNAdaptController (assumes content is already empty) */
SUNDIALS_EXPORT
void SUNAdaptController_DestroyEmpty(SUNAdaptController C);

/* Function to report the type of a SUNAdaptController object. */
SUNDIALS_EXPORT
SUNAdaptController_Type SUNAdaptController_GetType(SUNAdaptController C);
Expand Down
4 changes: 2 additions & 2 deletions src/arkode/arkode_relaxation.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,8 @@ static int arkRelaxBrentSolve(ARKodeMem ark_mem)
}

/* Compute and apply relaxation parameter */
int arkRelaxSolve(ARKodeMem ark_mem, ARKodeRelaxMem relax_mem,
sunrealtype* relax_val_out)
static int arkRelaxSolve(ARKodeMem ark_mem, ARKodeRelaxMem relax_mem,
sunrealtype* relax_val_out)
{
int retval;

Expand Down
72 changes: 36 additions & 36 deletions src/arkode/arkode_sprk.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "arkode/arkode_butcher.h"
#include "arkode_impl.h"

ARKodeSPRKTable ARKodeSymplecticEuler(void)
static ARKodeSPRKTable arkodeSymplecticEuler(void)
{
ARKodeSPRKTable sprk_table = ARKodeSPRKTable_Alloc(1);
if (!sprk_table) { return NULL; }
Expand All @@ -43,7 +43,7 @@ ARKodeSPRKTable ARKodeSymplecticEuler(void)
https://doi.org/10.1016/0021-9991(91)90299-Z.
*/

ARKodeSPRKTable ARKodeSymplecticLeapfrog2(void)
static ARKodeSPRKTable arkodeSymplecticLeapfrog2(void)
{
ARKodeSPRKTable sprk_table = ARKodeSPRKTable_Alloc(2);
if (!sprk_table) { return NULL; }
Expand All @@ -56,7 +56,7 @@ ARKodeSPRKTable ARKodeSymplecticLeapfrog2(void)
return sprk_table;
}

ARKodeSPRKTable ARKodeSymplecticPseudoLeapfrog2(void)
static ARKodeSPRKTable arkodeSymplecticPseudoLeapfrog2(void)
{
ARKodeSPRKTable sprk_table = ARKodeSPRKTable_Alloc(2);
if (!sprk_table) { return NULL; }
Expand All @@ -69,7 +69,7 @@ ARKodeSPRKTable ARKodeSymplecticPseudoLeapfrog2(void)
return sprk_table;
}

ARKodeSPRKTable ARKodeSymplecticCandyRozmus4(void)
static ARKodeSPRKTable arkodeSymplecticCandyRozmus4(void)
{
ARKodeSPRKTable sprk_table = ARKodeSPRKTable_Alloc(4);
if (!sprk_table) { return NULL; }
Expand Down Expand Up @@ -108,7 +108,7 @@ ARKodeSPRKTable ARKodeSymplecticCandyRozmus4(void)
https://accelconf.web.cern.ch/p83/PDF/PAC1983_2669.PDF
*/

ARKodeSPRKTable ARKodeSymplecticRuth3(void)
static ARKodeSPRKTable arkodeSymplecticRuth3(void)
{
ARKodeSPRKTable sprk_table = ARKodeSPRKTable_Alloc(3);
if (!sprk_table) { return NULL; }
Expand All @@ -130,7 +130,7 @@ ARKodeSPRKTable ARKodeSymplecticRuth3(void)
Nonlinearity. 5, 541–562 (1992). https://doi.org/10.1088/0951-7715/5/2/011
*/

ARKodeSPRKTable ARKodeSymplecticMcLachlan2(void)
static ARKodeSPRKTable arkodeSymplecticMcLachlan2(void)
{
ARKodeSPRKTable sprk_table = ARKodeSPRKTable_Alloc(2);
if (!sprk_table) { return NULL; }
Expand All @@ -145,7 +145,7 @@ ARKodeSPRKTable ARKodeSymplecticMcLachlan2(void)
return sprk_table;
}

ARKodeSPRKTable ARKodeSymplecticMcLachlan3(void)
static ARKodeSPRKTable arkodeSymplecticMcLachlan3(void)
{
sunrealtype w = SUN_RCONST(0.0);
sunrealtype y = SUN_RCONST(0.0);
Expand Down Expand Up @@ -175,7 +175,7 @@ ARKodeSPRKTable ARKodeSymplecticMcLachlan3(void)
return sprk_table;
}

ARKodeSPRKTable ARKodeSymplecticMcLachlan4(void)
static ARKodeSPRKTable arkodeSymplecticMcLachlan4(void)
{
ARKodeSPRKTable sprk_table = ARKodeSPRKTable_Alloc(4);
if (!sprk_table) { return NULL; }
Expand All @@ -192,7 +192,7 @@ ARKodeSPRKTable ARKodeSymplecticMcLachlan4(void)
return sprk_table;
}

ARKodeSPRKTable ARKodeSymplecticMcLachlan5(void)
static ARKodeSPRKTable arkodeSymplecticMcLachlan5(void)
{
ARKodeSPRKTable sprk_table = ARKodeSPRKTable_Alloc(6);
if (!sprk_table) { return NULL; }
Expand Down Expand Up @@ -222,7 +222,7 @@ ARKodeSPRKTable ARKodeSymplecticMcLachlan5(void)
*/

ARKodeSPRKTable ARKodeSymplecticYoshida6(void)
static ARKodeSPRKTable arkodeSymplecticYoshida6(void)
{
ARKodeSPRKTable sprk_table = ARKodeSPRKTable_Alloc(8);
if (!sprk_table) { return NULL; }
Expand Down Expand Up @@ -261,7 +261,7 @@ ARKodeSPRKTable ARKodeSymplecticYoshida6(void)
*/

ARKodeSPRKTable ARKodeSymplecticSuzukiUmeno816(void)
static ARKodeSPRKTable arkodeSymplecticSuzukiUmeno816(void)
{
ARKodeSPRKTable sprk_table = ARKodeSPRKTable_Alloc(16);
if (!sprk_table) { return NULL; }
Expand Down Expand Up @@ -311,7 +311,7 @@ ARKodeSPRKTable ARKodeSymplecticSuzukiUmeno816(void)
*/

ARKodeSPRKTable ARKodeSymplecticSofroniou10(void)
static ARKodeSPRKTable arkodeSymplecticSofroniou10(void)
{
ARKodeSPRKTable sprk_table = ARKodeSPRKTable_Alloc(36);
if (!sprk_table) { return NULL; }
Expand Down Expand Up @@ -453,19 +453,19 @@ ARKodeSPRKTable ARKodeSPRKTable_Load(ARKODE_SPRKMethodID id)
{
switch (id)
{
case ARKODE_SPRK_EULER_1_1: return ARKodeSymplecticEuler();
case ARKODE_SPRK_LEAPFROG_2_2: return ARKodeSymplecticLeapfrog2();
case ARKODE_SPRK_EULER_1_1: return arkodeSymplecticEuler();
case ARKODE_SPRK_LEAPFROG_2_2: return arkodeSymplecticLeapfrog2();
case ARKODE_SPRK_PSEUDO_LEAPFROG_2_2:
return ARKodeSymplecticPseudoLeapfrog2();
case ARKODE_SPRK_RUTH_3_3: return ARKodeSymplecticRuth3();
case ARKODE_SPRK_MCLACHLAN_2_2: return ARKodeSymplecticMcLachlan2();
case ARKODE_SPRK_MCLACHLAN_3_3: return ARKodeSymplecticMcLachlan3();
case ARKODE_SPRK_MCLACHLAN_4_4: return ARKodeSymplecticMcLachlan4();
case ARKODE_SPRK_CANDY_ROZMUS_4_4: return ARKodeSymplecticCandyRozmus4();
case ARKODE_SPRK_MCLACHLAN_5_6: return ARKodeSymplecticMcLachlan5();
case ARKODE_SPRK_YOSHIDA_6_8: return ARKodeSymplecticYoshida6();
case ARKODE_SPRK_SUZUKI_UMENO_8_16: return ARKodeSymplecticSuzukiUmeno816();
case ARKODE_SPRK_SOFRONIOU_10_36: return ARKodeSymplecticSofroniou10();
return arkodeSymplecticPseudoLeapfrog2();
case ARKODE_SPRK_RUTH_3_3: return arkodeSymplecticRuth3();
case ARKODE_SPRK_MCLACHLAN_2_2: return arkodeSymplecticMcLachlan2();
case ARKODE_SPRK_MCLACHLAN_3_3: return arkodeSymplecticMcLachlan3();
case ARKODE_SPRK_MCLACHLAN_4_4: return arkodeSymplecticMcLachlan4();
case ARKODE_SPRK_CANDY_ROZMUS_4_4: return arkodeSymplecticCandyRozmus4();
case ARKODE_SPRK_MCLACHLAN_5_6: return arkodeSymplecticMcLachlan5();
case ARKODE_SPRK_YOSHIDA_6_8: return arkodeSymplecticYoshida6();
case ARKODE_SPRK_SUZUKI_UMENO_8_16: return arkodeSymplecticSuzukiUmeno816();
case ARKODE_SPRK_SOFRONIOU_10_36: return arkodeSymplecticSofroniou10();
default: return NULL;
}
}
Expand All @@ -474,51 +474,51 @@ ARKodeSPRKTable ARKodeSPRKTable_LoadByName(const char* method)
{
if (!strcmp(method, "ARKODE_SPRK_EULER_1_1"))
{
return ARKodeSymplecticEuler();
return arkodeSymplecticEuler();
}
if (!strcmp(method, "ARKODE_SPRK_LEAPFROG_2_2"))
{
return ARKodeSymplecticLeapfrog2();
return arkodeSymplecticLeapfrog2();
}
if (!strcmp(method, "ARKODE_SPRK_PSEUDO_LEAPFROG_2_2"))
{
return ARKodeSymplecticPseudoLeapfrog2();
return arkodeSymplecticPseudoLeapfrog2();
}
if (!strcmp(method, "ARKODE_SPRK_RUTH_3_3"))
{
return ARKodeSymplecticRuth3();
return arkodeSymplecticRuth3();
}
if (!strcmp(method, "ARKODE_SPRK_MCLACHLAN_2_2"))
{
return ARKodeSymplecticMcLachlan2();
return arkodeSymplecticMcLachlan2();
}
if (!strcmp(method, "ARKODE_SPRK_MCLACHLAN_3_3"))
{
return ARKodeSymplecticMcLachlan3();
return arkodeSymplecticMcLachlan3();
}
if (!strcmp(method, "ARKODE_SPRK_MCLACHLAN_4_4"))
{
return ARKodeSymplecticMcLachlan4();
return arkodeSymplecticMcLachlan4();
}
if (!strcmp(method, "ARKODE_SPRK_CANDY_ROZMUS_4_4"))
{
return ARKodeSymplecticCandyRozmus4();
return arkodeSymplecticCandyRozmus4();
}
if (!strcmp(method, "ARKODE_SPRK_MCLACHLAN_5_6"))
{
return ARKodeSymplecticMcLachlan5();
return arkodeSymplecticMcLachlan5();
}
if (!strcmp(method, "ARKODE_SPRK_YOSHIDA_6_8"))
{
return ARKodeSymplecticYoshida6();
return arkodeSymplecticYoshida6();
}
if (!strcmp(method, "ARKODE_SPRK_SUZUKI_UMENO_8_16"))
{
return ARKodeSymplecticSuzukiUmeno816();
return arkodeSymplecticSuzukiUmeno816();
}
if (!strcmp(method, "ARKODE_SPRK_SOFRONIOU_10_36"))
{
return ARKodeSymplecticSofroniou10();
return arkodeSymplecticSofroniou10();
}
return NULL;
}
Expand Down
15 changes: 0 additions & 15 deletions src/arkode/arkode_sprkstep_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,16 +414,6 @@ int SPRKStepPrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt)
return (ARKodePrintAllStats(arkode_mem, outfile, fmt));
}

void SPRKStepPrintMem(void* arkode_mem, FILE* outfile)
{
ARKodePrintMem(arkode_mem, outfile);
}

int SPRKStepSetMaxNumConstrFails(void* arkode_mem, int maxfails)
{
return (ARKodeSetMaxNumConstrFails(arkode_mem, maxfails));
}

int SPRKStepWriteParameters(void* arkode_mem, FILE* fp)
{
return (ARKodeWriteParameters(arkode_mem, fp));
Expand All @@ -436,11 +426,6 @@ int SPRKStepGetStepStats(void* arkode_mem, long int* nsteps,
return (ARKodeGetStepStats(arkode_mem, nsteps, hinused, hlast, hcur, tcur));
}

int SPRKStepGetNumConstrFails(void* arkode_mem, long int* nconstrfails)
{
return (ARKodeGetNumConstrFails(arkode_mem, nconstrfails));
}

void SPRKStepFree(void** arkode_mem) { ARKodeFree(arkode_mem); }

/*===============================================================
Expand Down
2 changes: 0 additions & 2 deletions src/ida/ida_ic.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@
*/

extern int IDAInitialSetup(IDAMem IDA_mem);
extern sunrealtype IDAWrmsNorm(IDAMem IDA_mem, N_Vector x, N_Vector w,
sunbooleantype mask);

static int IDAnlsIC(IDAMem IDA_mem);
static int IDANewtonIC(IDAMem IDA_mem);
Expand Down
7 changes: 0 additions & 7 deletions src/idas/idas_ic.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@
*/

extern int IDAInitialSetup(IDAMem IDA_mem);
extern sunrealtype IDAWrmsNorm(IDAMem IDA_mem, N_Vector x, N_Vector w,
sunbooleantype mask);
extern sunrealtype IDASensWrmsNorm(IDAMem IDA_mem, N_Vector* xS, N_Vector* wS,
sunbooleantype mask);
extern sunrealtype IDASensWrmsNormUpdate(IDAMem IDA_mem, sunrealtype old_nrm,
N_Vector* xS, N_Vector* wS,
sunbooleantype mask);

extern int IDASensEwtSet(IDAMem IDA_mem, N_Vector* yScur, N_Vector* weightS);

Expand Down
3 changes: 0 additions & 3 deletions src/nvector/manyvector/nvector_manyvector.c
Original file line number Diff line number Diff line change
Expand Up @@ -595,9 +595,6 @@ MPI_Comm N_VGetCommunicator_MPIManyVector(N_Vector v)
{
return (MANYVECTOR_COMM(v));
}
#else
/* This function retrieves the MPI Communicator from a ManyVector object. */
SUNComm N_VGetCommunicator_ManyVector(N_Vector v) { return SUN_COMM_NULL; }
#endif

/* This function retrieves the global length of a ManyVector object. */
Expand Down
Loading

0 comments on commit cbbaca3

Please sign in to comment.