Skip to content

Commit

Permalink
Fix gcc10 warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
rickgaiser committed Dec 5, 2020
1 parent c77b0d4 commit efcc15a
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 41 deletions.
2 changes: 1 addition & 1 deletion ee_core/src/modmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ int LoadElf(const char *path, t_ExecData *data)
/*----------------------------------------------------------------------------------------*/
void ChangeModuleName(const char *name, const char *newname)
{
u8 search_name[60];
char search_name[60];
smod_mod_info_t info;
int len;

Expand Down
10 changes: 5 additions & 5 deletions ee_core/src/patches.c
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ static void ProSnowboarderPatch(void)

static int ShadowMan2_SifLoadModuleHook(const char *path, int arg_len, const char *args)
{
int (*pSifLoadModule)(const char *path, int arg_len, const char *args);
//int (*pSifLoadModule)(const char *path, int arg_len, const char *args);
void *(*pSifAllocIopHeap)(int size);
int (*pSifFreeIopHeap)(void *addr);
int (*pSifLoadModuleBuffer)(void *ptr, int arg_len, const char *args);
Expand All @@ -741,25 +741,25 @@ static int ShadowMan2_SifLoadModuleHook(const char *path, int arg_len, const cha

switch (g_mode) {
case 1: //NTSC-U/C
pSifLoadModule = (void *)0x00234188;
//pSifLoadModule = (void *)0x00234188;
pSifAllocIopHeap = (void *)0x239df0;
pSifFreeIopHeap = (void *)0x239f58;
pSifLoadModuleBuffer = (void *)0x00233f20;
break;
case 2: //PAL
pSifLoadModule = (void *)0x002336c8;
//pSifLoadModule = (void *)0x002336c8;
pSifAllocIopHeap = (void *)0x00239330;
pSifFreeIopHeap = (void *)0x00239498;
pSifLoadModuleBuffer = (void *)0x00233460;
break;
case 3: //PAL German
pSifLoadModule = (void *)0x00233588;
//pSifLoadModule = (void *)0x00233588;
pSifAllocIopHeap = (void *)0x002391f0;
pSifFreeIopHeap = (void *)0x00239358;
pSifLoadModuleBuffer = (void *)0x00233320;
break;
default:
pSifLoadModule = NULL;
//pSifLoadModule = NULL;
pSifAllocIopHeap = NULL;
pSifFreeIopHeap = NULL;
pSifLoadModuleBuffer = NULL;
Expand Down
2 changes: 1 addition & 1 deletion elfldr/elfldr.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

static inline void _strcpy(char *dst, const char *src)
{
strncpy(dst, src, strlen(src) + 1);
memcpy(dst, src, strlen(src) + 1);
}

static inline void _strcat(char *dst, const char *src)
Expand Down
6 changes: 3 additions & 3 deletions include/fntsys.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ void fntRelease(int id);
void fntUpdateAspectRatio();

/** Renders a text with specified window dimensions */
int fntRenderString(int id, int x, int y, short aligned, size_t width, size_t height, const unsigned char *string, u64 colour);
int fntRenderString(int id, int x, int y, short aligned, size_t width, size_t height, const char *string, u64 colour);

/** replaces spaces with newlines so that the text fits into the specified width.
* @note A destrutive operation - modifies the given string!
*/
void fntFitString(int id, unsigned char *string, size_t width);
void fntFitString(int id, char *string, size_t width);

/** Calculates the width of the given text string
* We can't use the height for alignment, as the horizontal center would depends of the contained text itself */
int fntCalcDimensions(int id, const unsigned char *str);
int fntCalcDimensions(int id, const char *str);

#endif
4 changes: 2 additions & 2 deletions include/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,13 @@ void guiCheckNotifications(int checkTheme, int checkLang);
* @param type the io operation type
* @param data the data for the operation
*/
void guiHandleDeferedIO(int *ptr, const unsigned char *message, int type, void *data);
void guiHandleDeferedIO(int *ptr, const char *message, int type, void *data);

void guiGameHandleDeferedIO(int *ptr, struct UIItem *ui, int type, void *data);

/** Renders a single frame with a specified message on the screen
*/
void guiRenderTextScreen(const unsigned char *message);
void guiRenderTextScreen(const char *message);

void guiWarning(const char *text, int count);

Expand Down
2 changes: 1 addition & 1 deletion include/mcemu.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

typedef struct
{
u8 magic[40];
char magic[40];
u16 page_size;
u16 pages_per_cluster;
u16 pages_per_block;
Expand Down
2 changes: 1 addition & 1 deletion include/utf8.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ static const uint8_t utf8d[] = {
1, 3, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // s7..s8
};

uint32_t inline utf8Decode(uint32_t *state, uint32_t *codep, uint32_t byte)
uint32_t static utf8Decode(uint32_t *state, uint32_t *codep, uint32_t byte)
{
uint32_t type = utf8d[byte];

Expand Down
2 changes: 1 addition & 1 deletion src/OSDHistory.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ int AddHistoryRecord(const char *name)
}

//Initialize the new entry.
strncpy(NewEntry->name, name, sizeof(NewEntry->name));
strncpy(NewEntry->name, name, sizeof(NewEntry->name) - 1);
NewEntry->LaunchCount = 1;
NewEntry->bitmask = 1;
NewEntry->ShiftAmount = 0;
Expand Down
8 changes: 4 additions & 4 deletions src/cheatman.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ static int is_empty_substr(const char *s, size_t count)
}

/* Max line length to parse */
#define LINE_MAX 255
#define CHEAT_LINE_MAX 255

/**
* parse_buf - Parse a text buffer for cheats.
Expand All @@ -242,7 +242,7 @@ static int is_empty_substr(const char *s, size_t count)
static int parse_buf(const char *buf)
{
code_t code;
char line[LINE_MAX + 1];
char line[CHEAT_LINE_MAX + 1];
int linenumber = 1;

if (buf == NULL)
Expand All @@ -255,8 +255,8 @@ static int parse_buf(const char *buf)
int len = chr_idx(buf, LF);
if (len < 0)
len = strlen(line);
else if (len > LINE_MAX)
len = LINE_MAX;
else if (len > CHEAT_LINE_MAX)
len = CHEAT_LINE_MAX;

if (!is_empty_substr(buf, len)) {
strncpy(line, buf, len);
Expand Down
20 changes: 10 additions & 10 deletions src/fntsys.c
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ static void fntRenderGlyph(fnt_glyph_cache_entry_t *glyph, int pen_x, int pen_y)


#ifndef __RTL
int fntRenderString(int id, int x, int y, short aligned, size_t width, size_t height, const unsigned char *string, u64 colour)
int fntRenderString(int id, int x, int y, short aligned, size_t width, size_t height, const char *string, u64 colour)
{
// wait for font lock to unlock
WaitSema(gFontSemaId);
Expand Down Expand Up @@ -593,7 +593,7 @@ static int isWeak(u32 character)
return (((character >= 0x0000 && character <= 0x0040) || (character >= 0x005B && character <= 0x0060) || (character >= 0x007B && character <= 0x00BF) || (character >= 0x00D7 && character <= 0x00F7) || (character >= 0x02B9 && character <= 0x02FF) || (character >= 0x2000 && character <= 0x2BFF)) ? 1 : 0);
}

static void fntRenderSubRTL(font_t *font, const unsigned char *startRTL, const unsigned char *string, fnt_glyph_cache_entry_t *glyph, int x, int y)
static void fntRenderSubRTL(font_t *font, const char *startRTL, const char *string, fnt_glyph_cache_entry_t *glyph, int x, int y)
{
if (glyph) {
x -= glyph->shx >> 6;
Expand Down Expand Up @@ -622,7 +622,7 @@ static void fntRenderSubRTL(font_t *font, const unsigned char *startRTL, const u
}
}

int fntRenderString(int id, int x, int y, short aligned, size_t width, size_t height, const unsigned char *string, u64 colour)
int fntRenderString(int id, int x, int y, short aligned, size_t width, size_t height, const char *string, u64 colour)
{
// wait for font lock to unlock
WaitSema(gFontSemaId);
Expand Down Expand Up @@ -662,7 +662,7 @@ int fntRenderString(int id, int x, int y, short aligned, size_t width, size_t he
short inRTL = 0;
int delta_x, pen_xRTL = 0;
fnt_glyph_cache_entry_t *glyphRTL = NULL;
const unsigned char *startRTL = NULL;
const char *startRTL = NULL;

// cache glyphs and render as we go
for (; *string; ++string) {
Expand Down Expand Up @@ -729,22 +729,22 @@ int fntRenderString(int id, int x, int y, short aligned, size_t width, size_t he
}
#endif

void fntFitString(int id, unsigned char *string, size_t width)
void fntFitString(int id, char *string, size_t width)
{
size_t cw = 0;
unsigned char *str = string;
char *str = string;
size_t spacewidth = fntCalcDimensions(id, " ");
unsigned char *psp = NULL;
char *psp = NULL;
width = rmScaleX(width);

while (*str) {
// scan forward to the next whitespace
unsigned char *sp = str;
char *sp = str;
for (; *sp && *sp != ' ' && *sp != '\n'; ++sp)
;

// store what was there before
unsigned char osp = *sp;
char osp = *sp;

// newline resets the situation
if (osp == '\n') {
Expand Down Expand Up @@ -786,7 +786,7 @@ void fntFitString(int id, unsigned char *string, size_t width)
}
}

int fntCalcDimensions(int id, const unsigned char *str)
int fntCalcDimensions(int id, const char *str)
{
int w = 0;

Expand Down
4 changes: 2 additions & 2 deletions src/gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -1538,7 +1538,7 @@ int guiMsgBox(const char *text, int addAccept, struct UIItem *ui)
return terminate - 1;
}

void guiHandleDeferedIO(int *ptr, const unsigned char *message, int type, void *data)
void guiHandleDeferedIO(int *ptr, const char *message, int type, void *data)
{
ioPutRequest(type, data);

Expand All @@ -1560,7 +1560,7 @@ void guiGameHandleDeferedIO(int *ptr, struct UIItem *ui, int type, void *data)
}
}

void guiRenderTextScreen(const unsigned char *message)
void guiRenderTextScreen(const char *message)
{
guiStartFrame();

Expand Down
5 changes: 2 additions & 3 deletions src/lang.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,7 @@ static int lngLoadFromFile(char *path, char *name)
if (fileBuffer) {
// file exists, try to read it and load the custom lang
char **curL = lang_strs;
char **newL = (char **)malloc(LANG_STR_COUNT * sizeof(char **));
memset(newL, 0, sizeof(char **));
char **newL = (char **)calloc(LANG_STR_COUNT, sizeof(char *));

int strId = 0;
while (strId < LANG_STR_COUNT && readFileBuffer(fileBuffer, &newL[strId])) {
Expand All @@ -368,7 +367,7 @@ static int lngLoadFromFile(char *path, char *name)
lngFreeFromFile(curL);

int len = strlen(path) - strlen(name) - 9; //-4 for extension, -5 for prefix
strncpy(dir, path, len);
memcpy(dir, path, len);
dir[len] = '\0';

lngLoadFont(dir, name);
Expand Down
7 changes: 0 additions & 7 deletions src/menusys.c
Original file line number Diff line number Diff line change
Expand Up @@ -868,9 +868,6 @@ void menuRenderMain()

void menuHandleInputMain()
{
// Last Played Auto Start
int ValidKeyPressed = 1;

if (getKey(KEY_LEFT)) {
menuPrevH();
} else if (getKey(KEY_RIGHT)) {
Expand Down Expand Up @@ -901,10 +898,6 @@ void menuHandleInputMain()
menuFirstPage();
} else if (getKeyOn(KEY_R2)) { // end
menuLastPage();

// Last Played Auto Start
} else { // None valid key pressed
ValidKeyPressed = 0;
}

// Last Played Auto Start
Expand Down

0 comments on commit efcc15a

Please sign in to comment.