i get this error and can't fix, i'm noob yet,if someone can help me i'll thank you this code come from xmplayer of libxenon (for jtag xbox)
(i try search similar error, but i can't find what's wrong)
int FileSortCallback(const void *f1, const void *f2) {
/* Special case for implicit directories */
if (((BROWSERENTRY *) f1)->filename[0] == '.' || ((BROWSERENTRY *) f2)->filename[0] == '.') {
if (strcmp(((BROWSERENTRY *) f1)->filename, ".") == 0) {
return -1;
}
if (strcmp(((BROWSERENTRY *) f2)->filename, ".") == 0) {
return 1;
}
if (strcmp(((BROWSERENTRY *) f1)->filename, "..") == 0) {
return -1;
}
if (strcmp(((BROWSERENTRY *) f2)->filename, "..") == 0) {
return 1;
}
}
/* If one is a file and one is a directory the directory is first. */
if (((BROWSERENTRY *) f1)->isdir && !(((BROWSERENTRY *) f2)->isdir)) return -1;
if (!(((BROWSERENTRY *) f1)->isdir) && ((BROWSERENTRY *) f2)->isdir) return 1;
//Ascending Name
if (XMPlayerCfg.sort_order == 0) {
return stricmp(((BROWSERENTRY *) f1)->filename, ((BROWSERENTRY *) f2)->filename);
}
//Descending Name
else if (XMPlayerCfg.sort_order == 1) {
return stricmp(((BROWSERENTRY *) f2)->filename, ((BROWSERENTRY *) f1)->filename);
}
//Date Ascending
else if (XMPlayerCfg.sort_order == 2) {
if ( ((BROWSERENTRY *) f2)->date == ((BROWSERENTRY *) f1)->date) { //if date is the same order by filename
return stricmp(((BROWSERENTRY *) f2)->filename, ((BROWSERENTRY *) f1)->filename);
} else {
return ((BROWSERENTRY *) f1)->date - ((BROWSERENTRY *) f2)->date;
}
}
//Date Descending
else if (XMPlayerCfg.sort_order == 3) {
if ( ((BROWSERENTRY *) f2)->date == ((BROWSERENTRY *) f1)->date) { //if date is the same order by filename
return stricmp(((BROWSERENTRY *) f1)->filename, ((BROWSERENTRY *) f2)->filename);
} else {
return ((BROWSERENTRY *) f2)->date - ((BROWSERENTRY *) f1)->date;
}
}
}
The compiler analyzes your code, and sees that a return statement will be executed for all values of sort_order
between 0
and 5
, inclusive. However, if the sort_order
is negative or more than 5
, the code would reach the end of the function without a return statement; that is why the compiler issues a warning.
Note that it may not be possible for sort_order
to be set to a negative number or a number over 5
because of constraints in other parts of your code. However, the compiler does not know any of that, so it thinks that sort_order
could have any value.
To fix this problem, add an unconditional return statement at the end.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With