Skip to content

Commit

Permalink
engine: use zero initializers instead of memset
Browse files Browse the repository at this point in the history
  • Loading branch information
a1batross committed Jan 14, 2025
1 parent 0412528 commit 4942672
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 9 deletions.
3 changes: 1 addition & 2 deletions engine/client/cl_demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -624,11 +624,10 @@ static void CL_ReadDemoUserCmd( qboolean discard )

if( !discard )
{
usercmd_t nullcmd;
const usercmd_t nullcmd = { 0 };
sizebuf_t buf;
demoangle_t *a;

memset( &nullcmd, 0, sizeof( nullcmd ));
MSG_Init( &buf, "UserCmd", data, sizeof( data ));

// a1ba: I have no proper explanation why
Expand Down
3 changes: 1 addition & 2 deletions engine/client/cl_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ CL_CreateCmd
*/
static void CL_CreateCmd( void )
{
usercmd_t nullcmd, *cmd;
usercmd_t nullcmd = { 0 }, *cmd;
runcmd_t *pcmd;
qboolean active;
double accurate_ms;
Expand Down Expand Up @@ -645,7 +645,6 @@ static void CL_CreateCmd( void )
}
else
{
memset( &nullcmd, 0, sizeof( nullcmd ));
cmd = &nullcmd;
}

Expand Down
6 changes: 2 additions & 4 deletions engine/common/hpak.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static void HPAK_CreatePak( const char *filename, resource_t *pResource, byte *p
string pakname;
byte md5[16];
file_t *fout;
MD5Context_t ctx;
MD5Context_t ctx = { 0 };

if( !COM_CheckString( filename ))
return;
Expand All @@ -125,7 +125,6 @@ static void HPAK_CreatePak( const char *filename, resource_t *pResource, byte *p
}

// let's hash it.
memset( &ctx, 0, sizeof( MD5Context_t ));
MD5Init( &ctx );

if( pData == NULL )
Expand Down Expand Up @@ -214,7 +213,7 @@ void HPAK_AddLump( qboolean bUseQueue, const char *name, resource_t *pResource,
file_t *file_src;
file_t *file_dst;
byte md5[16];
MD5Context_t ctx;
MD5Context_t ctx = { 0 };

if( pData == NULL && pFile == NULL )
return;
Expand All @@ -226,7 +225,6 @@ void HPAK_AddLump( qboolean bUseQueue, const char *name, resource_t *pResource,
}

// hash it
memset( &ctx, 0, sizeof( MD5Context_t ));
MD5Init( &ctx );

if( !pData )
Expand Down
2 changes: 1 addition & 1 deletion engine/common/identification.c
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ void GAME_EXPORT ID_SetCustomClientID( const char *id )

void ID_Init( void )
{
MD5Context_t hash = {0};
MD5Context_t hash = { 0 };
byte md5[16];
int i;

Expand Down

0 comments on commit 4942672

Please sign in to comment.