Some code smell fixes from sonarlint
This commit is contained in:
116
src/config.c
116
src/config.c
@@ -78,7 +78,10 @@
|
||||
#include <86box/ui.h>
|
||||
#include <86box/snd_opl.h>
|
||||
|
||||
static int cx, cy, cw, ch;
|
||||
static int cx;
|
||||
static int cy;
|
||||
static int cw;
|
||||
static int ch;
|
||||
static ini_t config;
|
||||
|
||||
/* TODO: Backwards compatibility, get rid of this when enough time has passed. */
|
||||
@@ -223,7 +226,8 @@ static void
|
||||
load_monitor(int monitor_index)
|
||||
{
|
||||
ini_section_t cat;
|
||||
char name[512], temp[512];
|
||||
char name[512];
|
||||
char temp[512];
|
||||
char *p = NULL;
|
||||
|
||||
sprintf(name, "Monitor #%i", monitor_index + 1);
|
||||
@@ -251,8 +255,14 @@ static void
|
||||
load_machine(void)
|
||||
{
|
||||
ini_section_t cat = ini_find_section(config, "Machine");
|
||||
char *p, *migrate_from = NULL;
|
||||
int c, i, j, speed, legacy_mfg, legacy_cpu;
|
||||
char *p;
|
||||
char *migrate_from = NULL;
|
||||
int c;
|
||||
int i;
|
||||
int j;
|
||||
int speed;
|
||||
int legacy_mfg;
|
||||
int legacy_cpu;
|
||||
double multi;
|
||||
|
||||
p = ini_section_get_string(cat, "machine", NULL);
|
||||
@@ -582,7 +592,8 @@ load_input_devices(void)
|
||||
{
|
||||
ini_section_t cat = ini_find_section(config, "Input devices");
|
||||
char temp[512];
|
||||
int c, d;
|
||||
int c;
|
||||
int d;
|
||||
char *p;
|
||||
|
||||
p = ini_section_get_string(cat, "mouse_type", NULL);
|
||||
@@ -770,7 +781,8 @@ load_network(void)
|
||||
ini_section_t cat = ini_find_section(config, "Network");
|
||||
char *p;
|
||||
char temp[512];
|
||||
uint16_t c = 0, min = 0;
|
||||
uint16_t c = 0;
|
||||
uint16_t min = 0;
|
||||
|
||||
/* Handle legacy configuration which supported only one NIC */
|
||||
p = ini_section_get_string(cat, "net_card", NULL);
|
||||
@@ -875,7 +887,8 @@ load_ports(void)
|
||||
ini_section_t cat = ini_find_section(config, "Ports (COM & LPT)");
|
||||
char *p;
|
||||
char temp[512];
|
||||
int c, d;
|
||||
int c;
|
||||
int d;
|
||||
|
||||
memset(temp, 0, sizeof(temp));
|
||||
|
||||
@@ -919,8 +932,10 @@ static void
|
||||
load_storage_controllers(void)
|
||||
{
|
||||
ini_section_t cat = ini_find_section(config, "Storage controllers");
|
||||
char *p, temp[512];
|
||||
int c, min = 0;
|
||||
char *p;
|
||||
char temp[512];
|
||||
int c;
|
||||
int min = 0;
|
||||
int free_p = 0;
|
||||
|
||||
/* TODO: Backwards compatibility, get rid of this when enough time has passed. */
|
||||
@@ -1042,15 +1057,18 @@ static void
|
||||
load_hard_disks(void)
|
||||
{
|
||||
ini_section_t cat = ini_find_section(config, "Hard disks");
|
||||
char temp[512], tmp2[512];
|
||||
char temp[512];
|
||||
char tmp2[512];
|
||||
char s[512];
|
||||
int c;
|
||||
char *p;
|
||||
uint32_t max_spt, max_hpc, max_tracks;
|
||||
uint32_t board = 0, dev = 0;
|
||||
uint32_t max_spt;
|
||||
uint32_t max_hpc;
|
||||
uint32_t max_tracks;
|
||||
uint32_t board = 0;
|
||||
uint32_t dev = 0;
|
||||
|
||||
memset(temp, '\0', sizeof(temp));
|
||||
for (c = 0; c < HDD_NUM; c++) {
|
||||
for (uint8_t c = 0; c < HDD_NUM; c++) {
|
||||
sprintf(temp, "hdd_%02i_parameters", c + 1);
|
||||
p = ini_section_get_string(cat, temp, "0, 0, 0, 0, none");
|
||||
sscanf(p, "%u, %u, %u, %i, %s",
|
||||
@@ -1243,13 +1261,13 @@ static void
|
||||
load_floppy_drives(void)
|
||||
{
|
||||
ini_section_t cat = ini_find_section(config, "Floppy drives");
|
||||
char temp[512], *p;
|
||||
int c;
|
||||
char temp[512];
|
||||
char *p;
|
||||
|
||||
if (!backwards_compat)
|
||||
return;
|
||||
|
||||
for (c = 0; c < FDD_NUM; c++) {
|
||||
for (uint8_t c = 0; c < FDD_NUM; c++) {
|
||||
sprintf(temp, "fdd_%02i_type", c + 1);
|
||||
p = ini_section_get_string(cat, temp, (c < 2) ? "525_2dd" : "none");
|
||||
fdd_set_type(c, fdd_get_from_internal_name(p));
|
||||
@@ -1304,10 +1322,14 @@ static void
|
||||
load_floppy_and_cdrom_drives(void)
|
||||
{
|
||||
ini_section_t cat = ini_find_section(config, "Floppy and CD-ROM drives");
|
||||
char temp[512], tmp2[512], *p;
|
||||
char temp[512];
|
||||
char tmp2[512];
|
||||
char *p;
|
||||
char s[512];
|
||||
unsigned int board = 0, dev = 0;
|
||||
int c, d = 0;
|
||||
unsigned int board = 0;
|
||||
unsigned int dev = 0;
|
||||
int c;
|
||||
int d = 0;
|
||||
|
||||
/* TODO: Backwards compatibility, get rid of this when enough time has passed. */
|
||||
backwards_compat = (cat == NULL);
|
||||
@@ -1524,10 +1546,14 @@ static void
|
||||
load_other_removable_devices(void)
|
||||
{
|
||||
ini_section_t cat = ini_find_section(config, "Other removable devices");
|
||||
char temp[512], tmp2[512], *p;
|
||||
char temp[512];
|
||||
char tmp2[512];
|
||||
char *p;
|
||||
char s[512];
|
||||
unsigned int board = 0, dev = 0;
|
||||
int c, d = 0;
|
||||
unsigned int board = 0;
|
||||
unsigned int dev = 0;
|
||||
int c;
|
||||
int d = 0;
|
||||
|
||||
/* TODO: Backwards compatibility, get rid of this when enough time has passed. */
|
||||
if (backwards_compat) {
|
||||
@@ -1802,7 +1828,7 @@ load_other_peripherals(void)
|
||||
ini_section_t cat = ini_find_section(config, "Other peripherals");
|
||||
char *p;
|
||||
char temp[512];
|
||||
int c, free_p = 0;
|
||||
int free_p = 0;
|
||||
|
||||
if (backwards_compat2) {
|
||||
p = ini_section_get_string(cat, "scsicard", NULL);
|
||||
@@ -1859,7 +1885,7 @@ load_other_peripherals(void)
|
||||
bugger_enabled = !!ini_section_get_int(cat, "bugger_enabled", 0);
|
||||
postcard_enabled = !!ini_section_get_int(cat, "postcard_enabled", 0);
|
||||
|
||||
for (c = 0; c < ISAMEM_MAX; c++) {
|
||||
for (uint8_t c = 0; c < ISAMEM_MAX; c++) {
|
||||
sprintf(temp, "isamem%d_type", c);
|
||||
|
||||
p = ini_section_get_string(cat, temp, "none");
|
||||
@@ -1980,7 +2006,8 @@ static void
|
||||
save_general(void)
|
||||
{
|
||||
ini_section_t cat = ini_find_or_create_section(config, "General");
|
||||
char temp[512], buffer[512] = { 0 };
|
||||
char temp[512];
|
||||
char buffer[512] = { 0 };
|
||||
|
||||
char *va_name;
|
||||
|
||||
@@ -2182,7 +2209,11 @@ save_machine(void)
|
||||
{
|
||||
ini_section_t cat = ini_find_or_create_section(config, "Machine");
|
||||
char *p;
|
||||
int c, i = 0, legacy_mfg, legacy_cpu = -1, closest_legacy_cpu = -1;
|
||||
int c;
|
||||
int i = 0;
|
||||
int legacy_mfg;
|
||||
int legacy_cpu = -1;
|
||||
int closest_legacy_cpu = -1;
|
||||
|
||||
p = machine_get_internal_name();
|
||||
ini_section_set_string(cat, "machine", p);
|
||||
@@ -2327,8 +2358,10 @@ static void
|
||||
save_input_devices(void)
|
||||
{
|
||||
ini_section_t cat = ini_find_or_create_section(config, "Input devices");
|
||||
char temp[512], tmp2[512];
|
||||
int c, d;
|
||||
char temp[512];
|
||||
char tmp2[512];
|
||||
int c;
|
||||
int d;
|
||||
|
||||
ini_section_set_string(cat, "mouse_type", mouse_get_internal_name(mouse_type));
|
||||
|
||||
@@ -2462,7 +2495,6 @@ save_sound(void)
|
||||
static void
|
||||
save_network(void)
|
||||
{
|
||||
int c = 0;
|
||||
char temp[512];
|
||||
ini_section_t cat = ini_find_or_create_section(config, "Network");
|
||||
|
||||
@@ -2470,7 +2502,7 @@ save_network(void)
|
||||
ini_section_delete_var(cat, "net_host_device");
|
||||
ini_section_delete_var(cat, "net_card");
|
||||
|
||||
for (c = 0; c < NET_CARD_MAX; c++) {
|
||||
for (uint8_t c = 0; c < NET_CARD_MAX; c++) {
|
||||
sprintf(temp, "net_%02i_card", c + 1);
|
||||
if (net_cards_conf[c].device_num == 0) {
|
||||
ini_section_delete_var(cat, temp);
|
||||
@@ -2522,7 +2554,8 @@ save_ports(void)
|
||||
{
|
||||
ini_section_t cat = ini_find_or_create_section(config, "Ports (COM & LPT)");
|
||||
char temp[512];
|
||||
int c, d;
|
||||
int c;
|
||||
int d;
|
||||
|
||||
for (c = 0; c < SERIAL_MAX; c++) {
|
||||
sprintf(temp, "serial%d_enabled", c + 1);
|
||||
@@ -2675,7 +2708,6 @@ save_other_peripherals(void)
|
||||
{
|
||||
ini_section_t cat = ini_find_or_create_section(config, "Other peripherals");
|
||||
char temp[512];
|
||||
int c;
|
||||
|
||||
if (bugger_enabled == 0)
|
||||
ini_section_delete_var(cat, "bugger_enabled");
|
||||
@@ -2687,7 +2719,7 @@ save_other_peripherals(void)
|
||||
else
|
||||
ini_section_set_int(cat, "postcard_enabled", postcard_enabled);
|
||||
|
||||
for (c = 0; c < ISAMEM_MAX; c++) {
|
||||
for (uint8_t c = 0; c < ISAMEM_MAX; c++) {
|
||||
sprintf(temp, "isamem%d_type", c);
|
||||
if (isamem_type[c] == 0)
|
||||
ini_section_delete_var(cat, temp);
|
||||
@@ -2710,12 +2742,12 @@ static void
|
||||
save_hard_disks(void)
|
||||
{
|
||||
ini_section_t cat = ini_find_or_create_section(config, "Hard disks");
|
||||
char temp[32], tmp2[512];
|
||||
char temp[32];
|
||||
char tmp2[512];
|
||||
char *p;
|
||||
int c;
|
||||
|
||||
memset(temp, 0x00, sizeof(temp));
|
||||
for (c = 0; c < HDD_NUM; c++) {
|
||||
for (uint8_t c = 0; c < HDD_NUM; c++) {
|
||||
sprintf(temp, "hdd_%02i_parameters", c + 1);
|
||||
if (hdd_is_valid(c)) {
|
||||
p = hdd_bus_to_string(hdd[c].bus, 0);
|
||||
@@ -2789,7 +2821,8 @@ static void
|
||||
save_floppy_and_cdrom_drives(void)
|
||||
{
|
||||
ini_section_t cat = ini_find_or_create_section(config, "Floppy and CD-ROM drives");
|
||||
char temp[512], tmp2[512];
|
||||
char temp[512];
|
||||
char tmp2[512];
|
||||
int c;
|
||||
|
||||
for (c = 0; c < FDD_NUM; c++) {
|
||||
@@ -2925,7 +2958,8 @@ static void
|
||||
save_other_removable_devices(void)
|
||||
{
|
||||
ini_section_t cat = ini_find_or_create_section(config, "Other removable devices");
|
||||
char temp[512], tmp2[512];
|
||||
char temp[512];
|
||||
char tmp2[512];
|
||||
int c;
|
||||
|
||||
for (c = 0; c < ZIP_NUM; c++) {
|
||||
@@ -3012,10 +3046,8 @@ save_other_removable_devices(void)
|
||||
void
|
||||
config_save(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
save_general(); /* General */
|
||||
for (i = 0; i < MONITORS_NUM; i++)
|
||||
for (uint8_t i = 0; i < MONITORS_NUM; i++)
|
||||
save_monitor(i);
|
||||
save_machine(); /* Machine */
|
||||
save_video(); /* Video */
|
||||
|
||||
Reference in New Issue
Block a user