fix various compiler warnings

This commit is contained in:
Taylor Richards committed 2025-08-18 11:59:22 -04:00
1 parent 908f306985
commit fc7389f95a
10 files changed
+21 -24

No files matched your search

+1 -1
View File
@@ -902,7 +902,7 @@ static CFILE *cf_open_fill_cfblock(const char* source, int line, const char* ori
cfp->source_file = source;
cfp->line_num = line;
int pos = ftell(fp);
auto pos = ftell(fp);
if(pos == -1L)
pos = 0;
cf_init_lowlevel_read_code(cfp,0,filelength(fileno(fp)), 0 );
+1 -1
View File
@@ -143,7 +143,7 @@ void lz41_load_offsets(CFILE* cf)
int* offsets_ptr = cf->compression_info.offsets;
/* Seek to the first offset position, remember to consider the trailing ints */
fso_fseek(cf, ( ( sizeof(int) * cf->compression_info.num_offsets ) * -1 ) - (sizeof(int)*3 ), SEEK_END);
fso_fseek(cf, static_cast<int>( ( sizeof(int) * cf->compression_info.num_offsets ) * -1 ) - (sizeof(int)*3 ), SEEK_END);
for (block = 0; block < cf->compression_info.num_offsets; ++block)
{
auto bytes_read = fread(offsets_ptr++, sizeof(int), 1, cf->fp);
+2 -2
View File
@@ -1083,7 +1083,7 @@ void dc_stuff_int(int *i)
value_l = dc_parse_long(token.c_str(), DCT_INT);
if ((value_l < INT_MAX) && (value_l > INT_MIN)) {
*i = value_l;
*i = static_cast<int>(value_l);
} else {
throw errParse(token.c_str(), DCT_INT);
@@ -1101,7 +1101,7 @@ void dc_stuff_uint(uint *i)
value_l = dc_parse_long(Cp, DCT_INT);
if (value_l < UINT_MAX) {
*i = value_l;
*i = static_cast<uint>(value_l);
} else {
throw errParse(token.c_str(), DCT_INT);
+2 -2
View File
@@ -392,7 +392,7 @@ int ChttpGet::ConnectSocket()
char *ChttpGet::GetHTTPLine()
{
int iBytesRead;
long iBytesRead;
char chunk[2];
uint igotcrlf = 0;
memset(recv_buffer,0,1000);
@@ -463,7 +463,7 @@ char *ChttpGet::GetHTTPLine()
uint ChttpGet::ReadDataChannel()
{
char sDataBuffer[4096]; // Data-storage buffer for the data channel
int nBytesRecv = 0; // Bytes received from the data channel
long nBytesRecv = 0; // Bytes received from the data channel
fd_set wfds;
+2 -2
View File
@@ -941,7 +941,7 @@ void draw_3d_overhead_view(int model_num,
gr_curve(lineendx, lineendy, 5, curve, resize_mode);
if (curve == 0 || curve == 1) {
lineendy = bank_coords[x][1] + lround(bank_y_offset * 1.5);
lineendy = bank_coords[x][1] + static_cast<int>(lround(bank_y_offset * 1.5));
} else {
lineendy = bank_coords[x][1] + (bank_y_offset / 2);
}
@@ -1015,7 +1015,7 @@ void draw_3d_overhead_view(int model_num,
if (curve == 1 || curve == 2) {
lineendy = bank_coords[x + MAX_SHIP_PRIMARY_BANKS][1] + (bank_y_offset / 2);
} else {
lineendy = bank_coords[x + MAX_SHIP_PRIMARY_BANKS][1] + lround(bank_y_offset * 1.5);
lineendy = bank_coords[x + MAX_SHIP_PRIMARY_BANKS][1] + static_cast<int>(lround(bank_y_offset * 1.5));
}
gr_line(xc, lineendy, xc, yc, resize_mode);
+1 -1
View File
@@ -473,7 +473,7 @@ char *ChatGetString(void)
struct timeval timeout;
char ch[2];
char *p;
int bytesread;
long bytesread;
static char return_string[MAXCHATBUFFER];
timeout.tv_sec=0;
+3 -3
View File
@@ -3310,7 +3310,7 @@ void bitbuffer_put( bitbuffer *bitbuf, uint data, int bit_count )
{
uint mask;
mask = 1L << ( bit_count - 1 );
mask = 1U << ( bit_count - 1 );
while ( mask != 0) {
if ( mask & data ) {
bitbuf->rack |= bitbuf->mask;
@@ -3330,7 +3330,7 @@ uint bitbuffer_get_unsigned( bitbuffer *bitbuf, int bit_count )
uint local_mask;
uint return_value;
local_mask = 1L << ( bit_count - 1 );
local_mask = 1U << ( bit_count - 1 );
return_value = 0;
while ( local_mask != 0) {
@@ -3355,7 +3355,7 @@ int bitbuffer_get_signed( bitbuffer *bitbuf, int bit_count )
uint local_mask;
uint return_value;
local_mask = 1L << ( bit_count - 1 );
local_mask = 1U << ( bit_count - 1 );
return_value = 0;
while ( local_mask != 0) {
if ( bitbuf->mask == 0x80 ) {
+4 -8
View File
@@ -131,18 +131,14 @@ public:
}
void execute() override {
size_t foundPlayerIndex = MAX_PLAYERS;
for (size_t idx = 0; idx < MAX_PLAYERS; idx++) {
for (int idx = 0; idx < MAX_PLAYERS; idx++) {
if (MULTI_CONNECTED(Net_players[idx])) {
if (Net_players[idx].player_id == mPlayerId) {
foundPlayerIndex = idx;
multi_kick_player(idx, 0);
break;
}
}
}
if (foundPlayerIndex < MAX_PLAYERS) {
multi_kick_player(foundPlayerIndex, 0);
}
}
private:
int mPlayerId;
@@ -622,7 +618,7 @@ static bool webserverApiRequest(mg_connection *conn, const mg_request_info *ri)
std::string basicAuthValue = "Basic ";
basicAuthValue += base64_encode(reinterpret_cast<const unsigned char*>(userNameAndPassword.c_str()), userNameAndPassword.length());
basicAuthValue += base64_encode(reinterpret_cast<const unsigned char*>(userNameAndPassword.c_str()), static_cast<uint>(userNameAndPassword.length()));
const char* authValue = mg_get_header(conn, "Authorization");
if (authValue == NULL || strcmp(authValue, basicAuthValue.c_str()) != 0) {
+3 -2
View File
@@ -27633,8 +27633,9 @@ void maybe_write_to_event_log(int result)
{
char buffer [256];
int mask = generate_event_log_flags_mask(result);
sprintf(buffer, "Event: %s at mission time %d seconds (%d milliseconds)", Mission_events[Event_index].name.c_str(), f2i(Missiontime), f2i((longlong)Missiontime * MILLISECONDS_PER_SECOND));
int mask = generate_event_log_flags_mask(result);
int secs = f2i(Missiontime);
sprintf(buffer, "Event: %s at mission time %d seconds (%d milliseconds)", Mission_events[Event_index].name.c_str(), secs, secs * MILLISECONDS_PER_SECOND);
Current_event_log_buffer->push_back(buffer);
if (!Snapshot_all_events && (!(mask &= Mission_events[Event_index].mission_log_flags))) {
+2 -2
View File
@@ -43,7 +43,7 @@ int filelength(int fd)
if (fstat (fd, &buf) == -1)
return -1;
return buf.st_size;
return static_cast<int>(buf.st_size);
}
@@ -199,7 +199,7 @@ void _splitpath (const char *path, char * /*drive*/, char *dir, char *fname, cha
lp = ls + strlen(ls); // move to the end
}
int dist = lp-ls;
auto dist = lp-ls;
if (dist > (_MAX_FNAME-1))
dist = _MAX_FNAME-1;