time type bugs

Issue #5 resolved
sezero created an issue

I locally applied a patch to employ gcc printf function attributes and found several format string issues, most of which I already fixed and pushed to the repo here.

However there are some needing attention:

client/cl_ents.c: In function `CL_AddEntities':
client/cl_ents.c:1639: warning: int format, double arg (arg 2)
client/cl_ents.c:1639: warning: int format, double arg (arg 2)
client/cl_ents.c:1646: warning: int format, double arg (arg 2)
client/cl_ents.c:1646: warning: int format, double arg (arg 2)
client/keys.c: In function `Key_Event':
client/keys.c:940: warning: int format, double arg (arg 6)
client/keys.c:948: warning: int format, double arg (arg 6)
client/keys.c:967: warning: int format, double arg (arg 6)
server/sv_ccmds.c: In function `SV_Status_f':
server/sv_ccmds.c:822: warning: int format, double arg (arg 2)
server/sv_ccmds.c:822: warning: int format, double arg (arg 2)
ref_soft/r_misc.c: In function `R_PrintTimes':
ref_soft/r_misc.c:136: warning: int format, double arg (arg 3)
ref_soft/r_misc.c: In function `R_PrintDSpeeds':
ref_soft/r_misc.c:161: warning: int format, double arg (arg 3)
ref_soft/r_misc.c:161: warning: int format, double arg (arg 4)
ref_soft/r_misc.c:161: warning: int format, double arg (arg 5)
ref_soft/r_misc.c:161: warning: int format, double arg (arg 6)
ref_soft/r_misc.c:161: warning: int format, double arg (arg 7)
ref_soft/r_misc.c:161: warning: int format, double arg (arg 8)
ref_soft/r_misc.c:161: warning: int format, double arg (arg 9)

As far as I can see, the integral time type of quake2 was changed to floating point. But the above shows there are places need attending. For example, kbutton_t->downtime is double but it is parsed using atoi() instead of atof(). There may be more.

Comments (5)

  1. Frank Sapone

    Yes, the code was originally int and I changd it to use doubles because of the UCLOCK code. It was probably unnecessary, but anyways. How did you find those warnings?

    Frank

  2. sezero reporter

    I used gcc's printf funtion attributes. e.g. added

    __attribute__((__format__(__printf__,3,4)))
    

    to Com_sprintf(), added

    __attribute__((__format__(__printf__,1,2)))
    

    to Com_Printf(), etc.

    The relevant places needs fixing for floating point time, e.g. in keys.c, cl_input.c, etc.

  3. Frank Sapone

    The ones you show me just look like printfs that need to be changed from %i to %d. Or are you saying I need to keep tracing back to find atois and other stuff. The precision loss may be necessary because connecting to multiplayer servers still work. But I can try to change the rest to doubles as well and see if everything to still works.

    Frank

  4. Log in to comment