Merge pull request #74 from GravisZro/fix/warnings

Fix build warnings (NULL instead of '\0')
This commit is contained in:
Louis Gombert 2024-04-19 11:21:14 +00:00 committed by GitHub
commit 21fb443cb3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
21 changed files with 60 additions and 65 deletions

View File

@ -578,7 +578,7 @@ bool InitGameModule(char *name, module *mod) {
if (!cf_OpenLibrary(lib_name)) {
ddio_MakePath(tmp_dll_name, Base_directory, "netgames", name, NULL);
strcat(tmp_dll_name, ".d3m");
Multi_game_dll_name[0] = NULL;
Multi_game_dll_name[0] = '\0';
goto loaddll;
}
// get a temp file name

View File

@ -124,10 +124,6 @@
#include "hlsoundlib.h"
#include "soundload.h"
#ifndef MACINTOSH
#define IGNORE_TABLE(x) x
#endif
tceffect TCEffects[MAX_TCEFFECTS];
int Screen_roots[MAX_TELCOM_SCREENS];
bool Screen_has_effect_with_focus[MAX_TELCOM_SCREENS];

View File

@ -780,7 +780,9 @@ void PrintDedicatedMessage(const char *fmt, ...) {
#include "linux/linux_fix.h"
#include "errno.h"
#define BOOL bool
#define SOCKET unsigned int
#ifndef SOCKET
#define SOCKET int
#endif
#define SOCKADDR_IN sockaddr_in
#define SOCKADDR sockaddr
#define INVALID_SOCKET -1
@ -886,7 +888,7 @@ void ListenDedicatedSocket(void) {
new_socket->prev = NULL;
Head_sock = new_socket;
memcpy(&new_socket->addr, &conn_addr, sizeof(new_socket->addr));
new_socket->input[0] = NULL;
new_socket->input[0] = '\0';
new_socket->sock = incoming_socket;
new_socket->validated = false;
// Give the new connection the login prompt
@ -905,7 +907,7 @@ void DedicatedSocketputs(char *str) {
strcat(newstr, "\r\n");
} else {
buf[0] = str[i];
buf[1] = NULL;
buf[1] = '\0';
strcat(newstr, buf);
}
}
@ -963,7 +965,7 @@ void DedicatedReadTelnet(void) {
conn = DedicatedLogoutTelnet(conn);
break;
} else if (bytesread > 0) {
buf[1] = NULL;
buf[1] = '\0';
// When we see a CR, process the line
if ((buf[0] == 0x0a) || (buf[0] == 0x0d)) {
if (conn->input[0] == 0) {
@ -983,12 +985,12 @@ void DedicatedReadTelnet(void) {
if (conn->input[0] == '$') {
DLLInfo.input_string = conn->input;
CallGameDLL(EVT_CLIENT_INPUT_STRING, &DLLInfo);
conn->input[0] = NULL;
conn->input[0] = '\0';
return;
}
ParseLine(conn->input, command, operand, 255, 255);
conn->input[0] = NULL;
conn->input[0] = '\0';
if (!command[0])
return;
@ -1011,7 +1013,7 @@ void DedicatedReadTelnet(void) {
send(conn->sock, "\r\n", strlen("\r\n") + 1, 0);
PrintDedicatedMessage(TXT_DS_REMOTELOGGEDIN, inet_ntoa(conn->addr.sin_addr));
PrintDedicatedMessage("\n");
conn->input[0] = NULL;
conn->input[0] = '\0';
} else {
PrintDedicatedMessage(TXT_DS_BADPASS, inet_ntoa(conn->addr.sin_addr));
PrintDedicatedMessage("\n");
@ -1030,9 +1032,9 @@ void DedicatedReadTelnet(void) {
delstr[0] = 8;
delstr[1] = ' ';
delstr[2] = 8;
delstr[3] = NULL;
conn->input[strlen(conn->input) - 1] = NULL;
buf[1] = NULL;
delstr[3] = '\0';
conn->input[strlen(conn->input) - 1] = '\0';
buf[1] = '\0';
send(conn->sock, delstr, strlen(delstr), 0);
} else {
if (strlen(conn->input) + bytesread >= sizeof(conn->input)) {

View File

@ -322,14 +322,14 @@ void PageInAllData(void);
// Prompts user for filename and starts recording if successfull
void DemoToggleRecording() {
char szfile[_MAX_PATH * 2];
szfile[0] = NULL;
szfile[0] = '\0';
if (Demo_flags == DF_RECORDING) {
// Stop recording and close the file
cfclose(Demo_cfp);
Demo_flags = DF_NONE;
AddBlinkingHUDMessage(TXT_DEMOSAVED);
Demo_fname[0] = NULL;
Demo_fname[0] = '\0';
return;
} else if (Demo_flags == DF_PLAYBACK) {
// We can't record a demo while we are playing back a demo
@ -360,7 +360,7 @@ void DemoToggleRecording() {
} else {
// cfopen failed
AddBlinkingHUDMessage(TXT_DEMOCANTCREATE);
Demo_fname[0] = NULL;
Demo_fname[0] = '\0';
return;
}
}
@ -1429,7 +1429,7 @@ void DemoAbort(bool deletefile) {
Demo_flags = DF_NONE;
if (deletefile)
ddio_DeleteFile(Demo_fname);
Demo_fname[0] = NULL;
Demo_fname[0] = '\0';
return;
}
}

View File

@ -898,7 +898,7 @@ char *GetMultiCDPath(char *file) {
// Clear out any old path
// memset(filepath,0,_MAX_PATH*2);
filepath[0] = NULL;
filepath[0] = '\0';
for (i = 0; i < num_cd_files; i++) {
char *vol_filename;

View File

@ -453,7 +453,7 @@ bool AddMultipleLinesToHUDMessages(char *temp_message, ddgr_color color) {
// char word[HUD_MESSAGE_LENGTH*2];
char nextword[HUD_MESSAGE_LENGTH * 2];
static char thisline[HUD_MESSAGE_LENGTH * 2] = "";
thisline[0] = NULL;
thisline[0] = '\0';
strcpy(ourstr, temp_message);
p = strtok(ourstr, " ");
bool added = 0;
@ -467,7 +467,7 @@ bool AddMultipleLinesToHUDMessages(char *temp_message, ddgr_color color) {
strcpy(nextword, p);
if ((grtext_GetTextLineWidth(thisline) + grtext_GetTextLineWidth(nextword)) > (Game_window_w * .7)) {
if (thisline[strlen(thisline) - 1] == ' ')
thisline[strlen(thisline) - 1] = NULL;
thisline[strlen(thisline) - 1] = '\0';
added |= AddLineToHUDMessages(thisline, color);
// Scan for color information in the string we just added
@ -482,13 +482,13 @@ bool AddMultipleLinesToHUDMessages(char *temp_message, ddgr_color color) {
thisline[i] = c[i];
thisline[4] = 0;
} else
thisline[0] = NULL;
thisline[0] = '\0';
}
p = nextword;
}
}
if (thisline[strlen(thisline) - 1] == ' ')
thisline[strlen(thisline) - 1] = NULL;
thisline[strlen(thisline) - 1] = '\0';
if (thisline[0])
added |= AddLineToHUDMessages(thisline, color);

View File

@ -1641,7 +1641,7 @@ void InitIOSystems(bool editor) {
int len = strlen(Base_directory);
for (int i = (len - 1); i >= 0; i--) {
if (i == '\\') {
Base_directory[i] = NULL;
Base_directory[i] = '\0';
}
}
mprintf((0, "Using working directory of %s\n", Base_directory));
@ -2210,7 +2210,7 @@ void InitD3Systems1(bool editor) {
strcpy(ipparse, GameArgs[tcplogarg + 1]);
pport = strchr(ipparse, ':');
if (pport) {
*pport = NULL;
*pport = '\0';
pport++;
port = atoi(pport);
}

View File

@ -924,13 +924,13 @@ bool ProcessCommandLine() {
char *tokp;
strcpy(szurl, GameArgs[urlarg]);
#ifdef DEMO
szurl[strlen("d3demo2://") - 1] = NULL; // Should make the string "d3demo:/"
szurl[strlen("d3demo2://") - 1] = '\0'; // Should make the string "d3demo:/"
p = szurl + strlen("d3demo2://"); // pointer to the first character of the url after the //
if (strcmpi(szurl, "d3demo2:/") == 0) {
mprintf((0, "Got a url passed: %s\n", p));
}
#else
szurl[strlen("descent3://") - 1] = NULL; // Should make the string "descent3:/"
szurl[strlen("descent3://") - 1] = '\0'; // Should make the string "descent3:/"
p = szurl + strlen("descent3://"); // pointer to the first character of the url after the //
if (strcmpi(szurl, "descent3:/") == 0) {
mprintf((0, "Got a url passed: %s\n", p));
@ -939,7 +939,7 @@ bool ProcessCommandLine() {
tokp = strtok(p, "/");
if (strcmpi(tokp, "ip") == 0) {
tokp = strtok(NULL, "/");
Auto_login_port[0] = NULL;
Auto_login_port[0] = '\0';
strcpy(Auto_login_addr, tokp);
// char seldll[_MAX_PATH*2];
// ddio_MakePath(seldll,Base_directory,"online","Direct TCP~IP Game.d3c",NULL);
@ -956,7 +956,7 @@ bool ProcessCommandLine() {
}
} else if (strcmpi(tokp, "pxo") == 0) {
tokp = strtok(NULL, "/");
Auto_login_port[0] = NULL;
Auto_login_port[0] = '\0';
strcpy(Auto_login_addr, tokp);
// char seldll[_MAX_PATH*2];
// ddio_MakePath(seldll,Base_directory,"online","parallax online.d3c",NULL);
@ -997,7 +997,7 @@ bool ProcessCommandLine() {
char *port = strchr(connhost, ':');
if (port) {
// terminate the hostname
*port = NULL;
*port = '\0';
// Increment to the first character of the port name
port++;
// get the port number

View File

@ -628,7 +628,7 @@ void msn_ClipURLToWidth(int width, char *string) {
int size = 0;
char save = string[0];
string[0] = NULL;
string[0] = '\0';
while (size < string_length) {
if ((grtext_GetTextLineWidth(string)) >= width) {
return;
@ -637,7 +637,7 @@ void msn_ClipURLToWidth(int width, char *string) {
string[size] = save;
size++;
save = string[size];
string[size] = NULL;
string[size] = '\0';
}
}
@ -648,7 +648,7 @@ char *msn_SecondsToString(int time_sec) {
int minutes;
int seconds;
int i;
fmttime[0] = NULL;
fmttime[0] = '\0';
hours = time_sec / 3600;
i = time_sec % 3600;
minutes = i / 60;

View File

@ -7950,7 +7950,7 @@ void MultiSendClientCustomData(int slot, int whoto) {
MultiAddShort(slot, data, &count);
// Send custom logo filename (all 0's if none)
csum_filename[0] = NULL;
csum_filename[0] = '\0';
if (NetPlayers[slot].ship_logo[0]) {
if (slot == Player_num) {
char szcrc[_MAX_PATH];
@ -8070,7 +8070,7 @@ void MultiDoCustomPlayerData(ubyte *data) {
char *GetFileNameFromPlayerAndID(short playernum, short id) {
static char rval[_MAX_PATH * 2];
rval[0] = NULL;
rval[0] = '\0';
if (playernum >= MAX_NET_PLAYERS) {
mprintf((0, "Invalid playernum (%d) passed to GetFileNameFromPlayerAndID()\n", playernum));
@ -8114,10 +8114,10 @@ char *GetFileNameFromPlayerAndID(short playernum, short id) {
cfp = cfopen(rval, "rb");
if (!cfp) {
mprintf((0, "Multiplayer file xfer File does not exist, not using file %d for player %d!\n", id, playernum));
// rval[0] = NULL;
// rval[0] = '\0';
} else if (32768 < cfilelength(cfp)) {
mprintf((0, "Multiplayer file xfer File to long, not using file %d for player %d!\n", id, playernum));
rval[0] = NULL;
rval[0] = '\0';
}
if (cfp)
cfclose(cfp);

View File

@ -62,7 +62,7 @@ int MultiSaveSettings(char *filename) {
int i;
cf = cfopen(filename, "wt");
if (!cf)
return NULL;
return 0;
sprintf(szoutput, "NAME\t%s", Netgame.name);
cf_WriteString(cf, szoutput);
sprintf(szoutput, "MISSION\t%s", Netgame.mission);
@ -126,7 +126,7 @@ int MultiLoadSettings(char *filename) {
int objid;
cf = cfopen(filename, "rt");
if (!cf)
return NULL;
return 0;
while (cf_ReadString(szinput, MAX_MPS_LINE_LEN - 1, cf)) {

View File

@ -672,7 +672,7 @@ int AutoConnectPXO() {
char *port = strchr(Auto_login_addr, ':');
if (port) {
// terminate the hostname
*port = NULL;
*port = '\0';
// Increment to the first character of the port name
port++;
// get the port number
@ -682,7 +682,7 @@ int AutoConnectPXO() {
if (portarg) {
strcpy(Auto_login_port, GameArgs[portarg + 1]);
} else {
Auto_login_port[0] = NULL;
Auto_login_port[0] = '\0';
}
}
@ -708,7 +708,7 @@ int AutoConnectLANIP() {
char *port = strchr(Auto_login_addr, ':');
if (port) {
// terminate the hostname
*port = NULL;
*port = '\0';
// Increment to the first character of the port name
port++;
// get the port number
@ -721,7 +721,7 @@ int AutoConnectLANIP() {
if (portarg) {
strcpy(Auto_login_port, GameArgs[portarg + 1]);
} else {
Auto_login_port[0] = NULL;
Auto_login_port[0] = '\0';
}
}
// ddio_MakePath(seldll,Base_directory,"online","Direct TCP~IP Game.d3c",NULL);
@ -746,7 +746,7 @@ int AutoConnectHeat() {
char *port = strchr(Auto_login_addr, ':');
if (port) {
// terminate the hostname
*port = NULL;
*port = '\0';
// Increment to the first character of the port name
port++;
// get the port number
@ -759,7 +759,7 @@ int AutoConnectHeat() {
if (portarg) {
strcpy(Auto_login_port, GameArgs[portarg + 1]);
} else {
Auto_login_port[0] = NULL;
Auto_login_port[0] = '\0';
}
}
if (LoadMultiDLL("HEAT.NET")) {
@ -1883,4 +1883,4 @@ no_players:
mem_free(Multi_recieved_player_list);
Multi_recieved_player_list = NULL;
}
}
}

View File

@ -577,7 +577,7 @@ void PaintPLRSinglePlayerText() {
if (tlen > curpos) {
line_progress[i] = curpos;
line_replace[i] = PLRText[i][curpos];
PLRText[i][curpos] = NULL;
PLRText[i][curpos] = '\0';
all_done_painting = false;
}
}
@ -666,4 +666,4 @@ const char *GetNormalizedRating(float mag)
return TXT(Stat_ratings[rating]);
}
*/
*/

View File

@ -1207,7 +1207,7 @@ int bm_w(int handle, int miplevel) {
}
if (GameBitmaps[handle].flags & BF_NOT_RESIDENT)
if (!bm_MakeBitmapResident(handle))
return NULL;
return 0;
if (!(GameBitmaps[handle].flags & BF_MIPMAPPED))
miplevel = 0;
w = GameBitmaps[handle].width;
@ -1224,7 +1224,7 @@ int bm_h(int handle, int miplevel) {
// If this bitmap is not page in, do so!
if (GameBitmaps[handle].flags & BF_NOT_RESIDENT)
if (!bm_MakeBitmapResident(handle))
return NULL;
return 0;
if (!(GameBitmaps[handle].flags & BF_MIPMAPPED))
miplevel = 0;
h = GameBitmaps[handle].height;
@ -1245,7 +1245,7 @@ int bm_miplevels(int handle) {
// If this bitmap is not page in, do so!
if (GameBitmaps[handle].flags & BF_NOT_RESIDENT)
if (!bm_MakeBitmapResident(handle))
return NULL;
return 0;
if (GameBitmaps[handle].flags & BF_MIPMAPPED) {
for (int tmp = GameBitmaps[handle].width; tmp > 0; tmp = tmp >> 1) {
levels++;
@ -1264,7 +1264,7 @@ int bm_mipped(int handle) {
// If this bitmap is not page in, do so!
if (GameBitmaps[handle].flags & BF_NOT_RESIDENT)
if (!bm_MakeBitmapResident(handle))
return NULL;
return 0;
if (GameBitmaps[handle].flags & BF_MIPMAPPED)
return 1;
return 0;
@ -1752,6 +1752,6 @@ int bm_format(int handle) {
}
if (GameBitmaps[handle].flags & BF_NOT_RESIDENT)
if (!bm_MakeBitmapResident(handle))
return NULL;
return 0;
return (GameBitmaps[handle].format);
}

View File

@ -402,7 +402,7 @@ bool CZip::AddFileToArchive(char *filename, int compression_type) {
// Add to the end of the file, so we need to move to the end, back up sizeof(int) to remove
// header
VFseek(bfile->file, 0 - sizeof(int), SEEK_END);
VFseek(bfile->file, int(0 - sizeof(int)), SEEK_END);
int compressed_size = -1;
int header_start = VFtell(bfile->file);

View File

@ -458,7 +458,7 @@ void grtext_Puts(int x, int y, const char *str) {
for (int a = 0; a < slen; a++)
lowerstr[a] = tolower(str[a]);
lowerstr[slen] = NULL;
lowerstr[slen] = '\0';
for (int i = 0; i < NUM_BAD_WORDS; i++) {
char *p = strstr(lowerstr, (char *)bad_words[i]);

View File

@ -202,10 +202,7 @@ inline void INADDR_GET_SUN_SUNB(struct in_addr *st, unsigned char *s_b1, unsigne
#include "linux/linux_fix.h"
#ifndef SOCKET
#define SOCKET int
#endif
#define BOOL bool
#define SOCKADDR_IN sockaddr_in
#define SOCKADDR_IPX sockaddr_ipx
@ -311,8 +308,8 @@ inline void INADDR_GET_SUN_SUNB(struct in_addr *st, unsigned char *s_b1, unsigne
#include "macsock.h"
#define SOCKET int
#define BOOL bool
#define SOCKET unsigned int
#define SOCKADDR_IN sockaddr_in
// #define SOCKADDR_IPX sockaddr_ipx
#define SOCKADDR sockaddr

View File

@ -91,7 +91,7 @@
#define BOOL bool
#ifndef SOCKET
#define SOCKET unsigned int
#define SOCKET int
#endif
#define SOCKADDR_IN sockaddr_in

View File

@ -751,7 +751,7 @@ int http_gethostbynameworker(void *parm)
if (he == NULL) {
lookup->error = true;
#ifdef __LINUX__
return NULL;
return 0;
#else
return;
#endif
@ -763,6 +763,6 @@ int http_gethostbynameworker(void *parm)
mem_free(lookup);
#ifdef __LINUX__
return NULL;
return 0;
#endif
}

View File

@ -110,4 +110,4 @@ IF(UNIX AND NOT APPLE)
DEPENDS ${SCRIPTS}
COMMENT "Building platform specific hog."
)
ENDIF()
ENDIF()

View File

@ -199,7 +199,7 @@ void UIEdit::SetText(char *text) {
void UIEdit::GetText(char *buffer, int len) {
// ASSERT(strlen(m_TextBuf) < (unsigned)len);
if (!m_TextBuf) {
buffer[0] = 0;
buffer[0] = '\0';
return;
}
strncpy(buffer, m_TextBuf, len - 1);