Bug 4812 - GCC __attribute__ annotations for printf, non-returning functions etc., patch by linux@youmustbejoking.demon.co.uk and Zack Middleton

This commit is contained in:
Thilo Schulz 2011-07-18 14:56:57 +00:00
parent 69a7ada911
commit 9dc32d55e2
30 changed files with 63 additions and 61 deletions

View file

@ -260,19 +260,10 @@ void QDECL Com_Error( int code, const char *fmt, ... ) {
va_list argptr;
static int lastErrorTime;
static int errorCount;
static qboolean calledSysError = qfalse;
int currentTime;
if(com_errorEntered)
{
if(!calledSysError)
{
calledSysError = qtrue;
Sys_Error("recursive error after: %s", com_errorMessage);
}
return;
}
Sys_Error("recursive error after: %s", com_errorMessage);
com_errorEntered = qtrue;
@ -348,7 +339,6 @@ void QDECL Com_Error( int code, const char *fmt, ... ) {
Com_Shutdown ();
calledSysError = qtrue;
Sys_Error ("%s", com_errorMessage);
}

View file

@ -849,7 +849,7 @@ qboolean Info_Validate( const char *s );
void Info_NextPair( const char **s, char *key, char *value );
// this is only here so the functions in q_shared.c and bg_*.c can link
void QDECL Com_Error( int level, const char *error, ... ) __attribute__ ((format (printf, 2, 3)));
void QDECL Com_Error( int level, const char *error, ... ) __attribute__ ((noreturn, format(printf, 2, 3)));
void QDECL Com_Printf( const char *msg, ... ) __attribute__ ((format (printf, 1, 2)));

View file

@ -821,8 +821,8 @@ void Com_BeginRedirect (char *buffer, int buffersize, void (*flush)(char *));
void Com_EndRedirect( void );
void QDECL Com_Printf( const char *fmt, ... ) __attribute__ ((format (printf, 1, 2)));
void QDECL Com_DPrintf( const char *fmt, ... ) __attribute__ ((format (printf, 1, 2)));
void QDECL Com_Error( int code, const char *fmt, ... ) __attribute__ ((format (printf, 2, 3)));
void Com_Quit_f( void );
void QDECL Com_Error( int code, const char *fmt, ... ) __attribute__ ((noreturn, format(printf, 2, 3)));
void Com_Quit_f( void ) __attribute__ ((noreturn));
void Com_GameRestart(int checksumFeed, qboolean disconnect);
int Com_Milliseconds( void ); // will be journaled properly
@ -1087,8 +1087,8 @@ void *Sys_GetBotLibAPI( void *parms );
char *Sys_GetCurrentUser( void );
void QDECL Sys_Error( const char *error, ...) __attribute__ ((format (printf, 1, 2)));
void Sys_Quit (void);
void QDECL Sys_Error( const char *error, ...) __attribute__ ((noreturn)) __attribute__ ((format (printf, 1, 2)));
void Sys_Quit (void) __attribute__ ((noreturn));
char *Sys_GetClipboardData( void ); // note that this isn't journaled...
void Sys_Print( const char *msg );

View file

@ -229,7 +229,7 @@ static unsigned char op_argsize[256] =
[OP_BLOCK_COPY] = 4,
};
void emit(const char* fmt, ...)
static __attribute__ ((format (printf, 1, 2))) void emit(const char* fmt, ...)
{
va_list ap;
char line[4096];
@ -381,26 +381,26 @@ static void* getentrypoint(vm_t* vm)
return vm->codeBase;
}
static void CROSSCALL eop(void)
static __attribute__ ((noreturn)) void CROSSCALL eop(void)
{
Com_Error(ERR_DROP, "End of program reached without return!");
exit(1);
}
static void CROSSCALL jmpviolation(void)
static __attribute__ ((noreturn)) void CROSSCALL jmpviolation(void)
{
Com_Error(ERR_DROP, "Program tried to execute code outside VM");
exit(1);
}
#ifdef DEBUG_VM
static void CROSSCALL memviolation(void)
static __attribute__ ((noreturn)) void CROSSCALL memviolation(void)
{
Com_Error(ERR_DROP, "Program tried to access memory outside VM, or unaligned memory access");
exit(1);
}
static void CROSSCALL opstackviolation(void)
static __attribute__ ((noreturn)) void CROSSCALL opstackviolation(void)
{
Com_Error(ERR_DROP, "Program corrupted the VM opStack");
exit(1);

View file

@ -30,6 +30,13 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include <inttypes.h>
// Ignore __attribute__ on non-gcc platforms
#ifndef __GNUC__
#ifndef __attribute__
#define __attribute__(x)
#endif
#endif
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
@ -55,7 +62,7 @@ static FILE* fout;
#define debug(fmt, args...)
#endif
static void _crap(const char* func, const char* fmt, ...)
static __attribute__ ((noreturn)) __attribute__ ((format (printf, 2, 3))) void _crap(const char* func, const char* fmt, ...)
{
va_list ap;
fprintf(stderr, "%s() - ", func);