Skip to content

Commit

Permalink
Codechange: Silence clang warnings about va_start (OpenTTD#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
glx22 authored Dec 27, 2023
1 parent 4d33593 commit c99d863
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/messages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ string mysprintf(const char*str,...){
static RenumMessageId curMessage;
#endif

string IssueMessage(int minSan,RenumMessageId id,...){
string internal::IssueMessage(int minSan,...){
va_list ap;
va_start(ap, id);
va_start(ap, minSan);
RenumMessageId id = (RenumMessageId)va_arg(ap, int);
string result = vIssueMessage(minSan,id,ap);
va_end(ap);
return result;
Expand Down
8 changes: 7 additions & 1 deletion src/messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,13 @@
// -------

std::string vIssueMessage(int,RenumMessageId,std::va_list&);
std::string IssueMessage(int,RenumMessageId,...);
namespace internal {
std::string IssueMessage(int,...);
}
template<typename... Targs>
std::string IssueMessage(int minSan,RenumMessageId id,Targs... Fargs) {
return internal::IssueMessage(minSan,id,Fargs...);
};
void AutoConsoleMessages();
void ManualConsoleMessages();
std::string mysprintf(const char*,...);
Expand Down
5 changes: 3 additions & 2 deletions src/sanity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,10 @@ void Before8(int action){
}
}

bool CheckLength(int alen,int elen,RenumMessageId message,...){
bool internal::CheckLength(int alen,int elen,...){
va_list ap;
va_start(ap, message);
va_start(ap, elen);
RenumMessageId message = (RenumMessageId)va_arg(ap, int);
if(alen<elen){
vIssueMessage(FATAL,message,ap);
return true;
Expand Down
9 changes: 7 additions & 2 deletions src/sanity_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@
#define _RENUM_SANITY_DEFS_H_INCLUDED_

#include "message_mgr.h"

bool CheckLength(int,int,RenumMessageId,...);
namespace internal {
bool CheckLength(int,int,...);
}
template<typename... Targs>
bool CheckLength(int alen,int elen,RenumMessageId id,Targs... Fargs) {
return internal::CheckLength(alen,elen,id,Fargs...);
}
bool CheckTextID(uint,uint,uint);
bool CheckID(uint,uint);

Expand Down

0 comments on commit c99d863

Please sign in to comment.