Yet more sonarlint fixes

This commit is contained in:
Jasmine Iwanek
2023-05-29 01:30:51 -04:00
parent 2e6634da89
commit ed1b369abd
125 changed files with 2557 additions and 2279 deletions

View File

@@ -63,7 +63,8 @@ SDL_mutex *blitmtx;
SDL_threadID eventthread;
static int exit_event = 0;
static int fullscreen_pending = 0;
uint32_t lang_id = 0x0409, lang_sys = 0x0409; // Multilangual UI variables, for now all set to LCID of en-US
uint32_t lang_id = 0x0409; // Multilangual UI variables, for now all set to LCID of en-US
uint32_t lang_sys = 0x0409; // Multilangual UI variables, for now all set to LCID of en-US
char icon_set[256] = ""; /* name of the iconset to be used */
static const uint16_t sdl_to_xt[0x200] = {
@@ -175,7 +176,10 @@ static const uint16_t sdl_to_xt[0x200] = {
};
typedef struct sdl_blit_params {
int x, y, w, h;
int x;
int y;
int w;
int h;
} sdl_blit_params;
sdl_blit_params params = { 0, 0, 0, 0 };
@@ -307,7 +311,7 @@ path_normalize(char *path)
void
path_slash(char *path)
{
if ((path[strlen(path) - 1] != '/')) {
if (path[strlen(path) - 1] != '/') {
strcat(path, "/");
}
path_normalize(path);
@@ -347,7 +351,7 @@ path_get_filename(char *s)
c--;
}
return (s);
return s;
}
char *
@@ -356,7 +360,7 @@ path_get_extension(char *s)
int c = strlen(s) - 1;
if (c <= 0)
return (s);
return s;
while (c && s[c] != '.')
c--;
@@ -417,7 +421,8 @@ plat_timer_read(void)
static uint64_t
plat_get_ticks_common(void)
{
uint64_t EndingTime, ElapsedMicroseconds;
uint64_t EndingTime;
uint64_t ElapsedMicroseconds;
if (first_use) {
Frequency = SDL_GetPerformanceFrequency();
StartingTime = SDL_GetPerformanceCounter();
@@ -519,8 +524,10 @@ strnicmp(const char *s1, const char *s2, size_t n)
void
main_thread(void *param)
{
uint32_t old_time, new_time;
int drawits, frames;
uint32_t old_time;
uint32_t new_time;
int drawits;
int frames;
SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH);
framecountx = 0;
@@ -693,7 +700,9 @@ ui_sb_bugui(char *str)
extern void sdl_blit(int x, int y, int w, int h);
typedef struct mouseinputdata {
int deltax, deltay, deltaz;
int deltax;
int deltay;
int deltaz;
int mousebuttons;
} mouseinputdata;
SDL_mutex *mousemutex;
@@ -710,7 +719,8 @@ mouse_poll(void)
SDL_UnlockMutex(mousemutex);
}
int real_sdl_w, real_sdl_h;
int real_sdl_w;
int real_sdl_h;
void
ui_sb_set_ready(int ready)
{
@@ -721,7 +731,8 @@ char *xargv[512];
char *
local_strsep(char **str, const char *sep)
{
char *s = *str, *end;
char *s = *str;
char *end;
if (!s)
return NULL;
end = s + strcspn(s, sep);
@@ -828,8 +839,7 @@ process_media_commands_3(uint8_t *id, char *fn, uint8_t *wp, int cmdargc)
bool err = false;
*id = atoi(xargv[1]);
if (xargv[2][0] == '\'' || xargv[2][0] == '"') {
int curarg = 2;
for (curarg = 2; curarg < cmdargc; curarg++) {
for (int curarg = 2; curarg < cmdargc; curarg++) {
if (strlen(fn) + strlen(xargv[curarg]) >= PATH_MAX) {
err = true;
fprintf(stderr, "Path name too long.\n");
@@ -989,7 +999,8 @@ monitor_thread(void *param)
} else if (strncasecmp(xargv[0], "zipeject", 8) == 0 && cmdargc >= 2) {
zip_eject(atoi(xargv[1]));
} else if (strncasecmp(xargv[0], "fddload", 7) == 0 && cmdargc >= 4) {
uint8_t id, wp;
uint8_t id;
uint8_t wp;
bool err = false;
char fn[PATH_MAX];
memset(fn, 0, sizeof(fn));
@@ -1008,7 +1019,8 @@ monitor_thread(void *param)
floppy_mount(id, fn, wp);
}
} else if (strncasecmp(xargv[0], "moload", 7) == 0 && cmdargc >= 4) {
uint8_t id, wp;
uint8_t id;
uint8_t wp;
bool err = false;
char fn[PATH_MAX];
memset(fn, 0, sizeof(fn));
@@ -1027,7 +1039,8 @@ monitor_thread(void *param)
mo_mount(id, fn, wp);
}
} else if (strncasecmp(xargv[0], "cartload", 7) == 0 && cmdargc >= 4) {
uint8_t id, wp;
uint8_t id;
uint8_t wp;
bool err = false;
char fn[PATH_MAX];
memset(fn, 0, sizeof(fn));
@@ -1046,7 +1059,8 @@ monitor_thread(void *param)
cartridge_mount(id, fn, wp);
}
} else if (strncasecmp(xargv[0], "zipload", 7) == 0 && cmdargc >= 4) {
uint8_t id, wp;
uint8_t id;
uint8_t wp;
bool err = false;
char fn[PATH_MAX];
memset(fn, 0, sizeof(fn));

View File

@@ -49,7 +49,9 @@ cassette_mount(char *fn, uint8_t wp)
if (fn != NULL)
memcpy(cassette_fname, fn, MIN(511, strlen(fn)));
ui_sb_update_icon_state(SB_CASSETTE, (fn == NULL) ? 1 : 0);
// media_menu_update_cassette();
#if 0
media_menu_update_cassette();
#endif
ui_sb_update_tip(SB_CASSETTE);
config_save();
}
@@ -60,7 +62,9 @@ cassette_eject(void)
pc_cas_set_fname(cassette, NULL);
memset(cassette_fname, 0x00, sizeof(cassette_fname));
ui_sb_update_icon_state(SB_CASSETTE, 1);
// media_menu_update_cassette();
#if 0
media_menu_update_cassette();
#endif
ui_sb_update_tip(SB_CASSETTE);
config_save();
}
@@ -71,7 +75,9 @@ cartridge_mount(uint8_t id, char *fn, uint8_t wp)
cart_close(id);
cart_load(id, fn);
ui_sb_update_icon_state(SB_CARTRIDGE | id, strlen(cart_fns[id]) ? 0 : 1);
// media_menu_update_cartridge(id);
#if 0
media_menu_update_cartridge(id);
#endif
ui_sb_update_tip(SB_CARTRIDGE | id);
config_save();
}
@@ -81,7 +87,9 @@ cartridge_eject(uint8_t id)
{
cart_close(id);
ui_sb_update_icon_state(SB_CARTRIDGE | id, 1);
// media_menu_update_cartridge(id);
#if 0
media_menu_update_cartridge(id);
#endif
ui_sb_update_tip(SB_CARTRIDGE | id);
config_save();
}
@@ -93,7 +101,9 @@ floppy_mount(uint8_t id, char *fn, uint8_t wp)
ui_writeprot[id] = wp;
fdd_load(id, fn);
ui_sb_update_icon_state(SB_FLOPPY | id, strlen(floppyfns[id]) ? 0 : 1);
// media_menu_update_floppy(id);
#if 0
media_menu_update_floppy(id);
#endif
ui_sb_update_tip(SB_FLOPPY | id);
config_save();
}
@@ -103,7 +113,9 @@ floppy_eject(uint8_t id)
{
fdd_close(id);
ui_sb_update_icon_state(SB_FLOPPY | id, 1);
// media_menu_update_floppy(id);
#if 0
media_menu_update_floppy(id);
#endif
ui_sb_update_tip(SB_FLOPPY | id);
config_save();
}
@@ -119,7 +131,9 @@ plat_cdrom_ui_update(uint8_t id, uint8_t reload)
ui_sb_update_icon_state(SB_CDROM | id, 0);
}
// media_menu_update_cdrom(id);
#if 0
media_menu_update_cdrom(id);
#endif
ui_sb_update_tip(SB_CDROM | id);
}
@@ -142,7 +156,9 @@ cdrom_mount(uint8_t id, char *fn)
} else {
ui_sb_update_icon_state(SB_CDROM | id, 1);
}
// media_menu_update_cdrom(id);
#if 0
media_menu_update_cdrom(id);
#endif
ui_sb_update_tip(SB_CDROM | id);
config_save();
}
@@ -159,7 +175,9 @@ mo_eject(uint8_t id)
}
ui_sb_update_icon_state(SB_MO | id, 1);
// media_menu_update_mo(id);
#if 0
media_menu_update_mo(id);
#endif
ui_sb_update_tip(SB_MO | id);
config_save();
}
@@ -175,7 +193,9 @@ mo_mount(uint8_t id, char *fn, uint8_t wp)
mo_insert(dev);
ui_sb_update_icon_state(SB_MO | id, strlen(mo_drives[id].image_path) ? 0 : 1);
// media_menu_update_mo(id);
#if 0
media_menu_update_mo(id);
#endif
ui_sb_update_tip(SB_MO | id);
config_save();
@@ -193,7 +213,9 @@ mo_reload(uint8_t id)
ui_sb_update_icon_state(SB_MO | id, 0);
}
// media_menu_update_mo(id);
#if 0
media_menu_update_mo(id);
#endif
ui_sb_update_tip(SB_MO | id);
config_save();
@@ -211,7 +233,9 @@ zip_eject(uint8_t id)
}
ui_sb_update_icon_state(SB_ZIP | id, 1);
// media_menu_update_zip(id);
#if 0
media_menu_update_zip(id);
#endif
ui_sb_update_tip(SB_ZIP | id);
config_save();
}
@@ -227,7 +251,9 @@ zip_mount(uint8_t id, char *fn, uint8_t wp)
zip_insert(dev);
ui_sb_update_icon_state(SB_ZIP | id, strlen(zip_drives[id].image_path) ? 0 : 1);
// media_menu_update_zip(id);
#if 0
media_menu_update_zip(id);
#endif
ui_sb_update_tip(SB_ZIP | id);
config_save();
@@ -245,7 +271,9 @@ zip_reload(uint8_t id)
ui_sb_update_icon_state(SB_ZIP | id, 0);
}
// media_menu_update_zip(id);
#if 0
media_menu_update_zip(id);
#endif
ui_sb_update_tip(SB_ZIP | id);
config_save();

View File

@@ -23,18 +23,27 @@
#define RENDERER_OPENGL 4
typedef struct sdl_blit_params {
int x, y, w, h;
int x;
int y;
int w;
int h;
} sdl_blit_params;
extern sdl_blit_params params;
extern int blitreq;
SDL_Window *sdl_win = NULL;
SDL_Renderer *sdl_render = NULL;
static SDL_Texture *sdl_tex = NULL;
int sdl_w = SCREEN_RES_X, sdl_h = SCREEN_RES_Y;
static int sdl_fs, sdl_flags = -1;
static int cur_w, cur_h;
static int cur_wx = 0, cur_wy = 0, cur_ww = 0, cur_wh = 0;
SDL_Window *sdl_win = NULL;
SDL_Renderer *sdl_render = NULL;
static SDL_Texture *sdl_tex = NULL;
int sdl_w = SCREEN_RES_X;
int sdl_h = SCREEN_RES_Y;
static int sdl_fs;
static int sdl_flags = -1;
static int cur_w;
static int cur_h;
static int cur_wx = 0;
static int cur_wy = 0;
static int cur_ww = 0;
static int cur_wh = 0;
static volatile int sdl_enabled = 1;
static SDL_mutex *sdl_mutex = NULL;
int mouse_capture;
@@ -43,7 +52,8 @@ int resize_pending = 0;
int resize_w = 0;
int resize_h = 0;
double mouse_sensitivity = 1.0; /* Unused. */
double mouse_x_error = 0.0, mouse_y_error = 0.0; /* Unused. */
double mouse_x_error = 0.0; /* Unused. */
double mouse_y_error = 0.0; /* Unused. */
static uint8_t interpixels[17842176];
extern void RenderImGui(void);
@@ -66,8 +76,18 @@ void sdl_reinit_texture(void);
static void
sdl_stretch(int *w, int *h, int *x, int *y)
{
double hw, gw, hh, gh, dx, dy, dw, dh, gsr, hsr;
int real_sdl_w, real_sdl_h;
double hw;
double gw;
double hh;
double gh;
double dx;
double dy;
double dw;
double dh;
double gsr;
double hsr;
int real_sdl_w;
int real_sdl_h;
SDL_GL_GetDrawableSize(sdl_win, &real_sdl_w, &real_sdl_h);
@@ -147,7 +167,9 @@ void
sdl_real_blit(SDL_Rect *r_src)
{
SDL_Rect r_dst;
int ret, winx, winy;
int ret;
int winx;
int winy;
SDL_GL_GetDrawableSize(sdl_win, &winx, &winy);
SDL_RenderClear(sdl_render);
@@ -273,10 +295,9 @@ sdl_enable(int enable)
static void
sdl_select_best_hw_driver(void)
{
int i;
SDL_RendererInfo renderInfo;
for (i = 0; i < SDL_GetNumRenderDrivers(); ++i) {
for (int i = 0; i < SDL_GetNumRenderDrivers(); ++i) {
SDL_GetRenderDriverInfo(i, &renderInfo);
if (renderInfo.flags & SDL_RENDERER_ACCELERATED) {
SDL_SetHint(SDL_HINT_RENDER_DRIVER, renderInfo.name);
@@ -321,7 +342,10 @@ sdl_set_fs(int fs)
void
sdl_resize(int x, int y)
{
int ww = 0, wh = 0, wx = 0, wy = 0;
int ww = 0;
int wh = 0;
int wx = 0;
int wy = 0;
if (video_fullscreen & 2)
return;
@@ -436,7 +460,7 @@ sdl_initho(void)
int
sdl_pause(void)
{
return (0);
return 0;
}
void

View File

@@ -87,20 +87,22 @@ plat_serpt_close(void *p)
static void
plat_serpt_write_vcon(serial_passthrough_t *dev, uint8_t data)
{
/* fd_set wrfds;
* int res;
*/
#if 0
fd_set wrfds;
int res;
#endif
/* We cannot use select here, this would block the hypervisor! */
/* FD_ZERO(&wrfds);
FD_SET(ctx->master_fd, &wrfds);
#if 0
FD_ZERO(&wrfds);
FD_SET(ctx->master_fd, &wrfds);
res = select(ctx->master_fd + 1, NULL, &wrfds, NULL, NULL);
res = select(ctx->master_fd + 1, NULL, &wrfds, NULL, NULL);
if (res <= 0) {
return;
}
*/
if (res <= 0) {
return;
}
#endif
/* just write it out */
if (dev->mode == SERPT_MODE_HOSTSER) {

View File

@@ -133,7 +133,7 @@ int
thread_wait_mutex(mutex_t *_mutex)
{
if (_mutex == NULL)
return (0);
return 0;
pt_mutex_t *mutex = (pt_mutex_t *) _mutex;
return pthread_mutex_lock(&mutex->mutex) != 0;
@@ -143,7 +143,7 @@ int
thread_test_mutex(mutex_t *_mutex)
{
if (_mutex == NULL)
return (0);
return 0;
pt_mutex_t *mutex = (pt_mutex_t *) _mutex;
return pthread_mutex_trylock(&mutex->mutex) != 0;
@@ -153,7 +153,7 @@ int
thread_release_mutex(mutex_t *_mutex)
{
if (_mutex == NULL)
return (0);
return 0;
pt_mutex_t *mutex = (pt_mutex_t *) _mutex;
return pthread_mutex_unlock(&mutex->mutex) != 0;