GRHydro: clean-up unused variables

Issue #906 closed
Bruno Mundim created an issue

I have attached a patch that clean-up unused variables in GRHydro. Is it ok to apply?

Keyword: GRHydro

Comments (7)

  1. Roland Haas
    • changed status to open
    • removed comment

    The patch applies and compiles and reduces the number of warnings. There are some leftover warnings afterwards that might be cleaned up at the same time:

    COMPILING GRHydro/src/GRHydro_Con2PrimM_pt.c GRHydro/src/GRHydro_Con2PrimM_pt.c: In function ‘grhydro_con2primm_pt_’: GRHydro/src/GRHydro_Con2PrimM_pt.c:214:32: warning: declaration of ‘gamma’ shadows a global declaration [-Wshadow] GRHydro/src/GRHydro_Con2PrimM_pt.c: In function ‘twod_newton_raphson’: GRHydro/src/GRHydro_Con2PrimM_pt.c:513:13: warning: variable ‘vsq_old’ set but not used [-Wunused-but-set-variable] GRHydro/src/GRHydro_Con2PrimM_pt.c: In function ‘func_vsq’: GRHydro/src/GRHydro_Con2PrimM_pt.c:629:22: warning: variable ‘Wsq’ set but not used [-Wunused-but-set-variable] GRHydro/src/GRHydro_Con2PrimM_pt.c: At top level: GRHydro/src/GRHydro_Con2PrimM_pt.c:479:13: warning: ‘validate_x’ defined but not used [-Wunused-function] COMPILING GRHydro/src/GRHydro_Con2PrimM_polytype_pt.c GRHydro/src/GRHydro_Con2PrimM_polytype_pt.c: In function ‘grhydro_con2primm_polytype_pt_’: GRHydro/src/GRHydro_Con2PrimM_polytype_pt.c:209:32: warning: declaration of ‘gamma’ shadows a global declaration [-Wshadow] GRHydro/src/GRHydro_Con2PrimM_polytype_pt.c: In function ‘oned_newton_raphson’: GRHydro/src/GRHydro_Con2PrimM_polytype_pt.c:496:13: warning: variable ‘W’ set but not used [-Wunused-but-set-variable] GRHydro/src/GRHydro_Con2PrimM_polytype_pt.c:492:27: warning: variable ‘x_old’ set but not used [-Wunused-but-set-variable] GRHydro/src/GRHydro_Con2PrimM_polytype_pt.c: In function ‘gnr2’: GRHydro/src/GRHydro_Con2PrimM_polytype_pt.c:696:27: warning: variable ‘x_old’ set but not used [-Wunused-but-set-variable] GRHydro/src/GRHydro_Con2PrimM_polytype_pt.c: At top level: GRHydro/src/GRHydro_Con2PrimM_polytype_pt.c:462:13: warning: ‘validate_x’ defined but not used [-Wunused-function]

    Otherwise fine to apply.

  2. Bruno Mundim reporter
    • changed status to resolved
    • removed comment

    Applied. The x_old complaint above seems odd to me. It does seem to be used. So I didn't apply that. The others I cleaned them up. Also the shadow gamma declaration seems to be due to gamma definition in math.h. I think we are safe here. validate_x: I didn't want to comment that out since I don't know if we are going to need it soon.

    Anyway I hope it is a bit cleaner now.

  3. Frank Löffler
    • removed comment

    x_old is used, but only for debug output, and only if DEBUG_CON2PRIMM is defined (which it probably wasn't for that compilation), so the compiler is in theory right. Maybe we can wrap x0 in #ifdefs for DEBUG_CON2PRIMM.

  4. Erik Schnetter
    • removed comment

    I believe this is a C routine. You could declare x_old where it is set for the first time.

  5. Frank Löffler
    • removed comment

    You could declare it where it is set, but I believe this would not help with the warning. The variable is already always set at the moment, but it even though it is set, it is never used (only in code which the compiler never sees). So - setting a variable to some value doesn't make it 'being used', because it never has the chance to change the outcome of the function in any way.

  6. Log in to comment