我得到这个错误,无法修复,我还是noob,如果有人可以帮助我,我会感谢你这个代码来自libxenon的xmplayer(对于jtag xbox)
(我尝试搜索类似的错误,但我找不到什么是错的)
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;
}
}
}Run Code Online (Sandbox Code Playgroud)
编译器分析你的代码,并看到一个return语句会为所有的值来执行sort_order之间0和5,包容性.但是,如果sort_order是负数或大于5,则代码将在没有return语句的情况下到达函数的末尾; 这就是编译器发出警告的原因.
请注意,由于代码其他部分的约束,可能无法将sort_order其设置为负数或数字5.但是,编译器不知道任何一个,所以它认为sort_order可以有任何值.
要解决此问题,请在末尾添加无条件return语句.
| 归档时间: |
|
| 查看次数: |
25974 次 |
| 最近记录: |