Warning[Pe111]: statement is unreachable

lingshawu 2011-10-18 10:32:55
Warning[Pe111]: statement is unreachable
用的是iar,用c写部分模块,给出了以上警告,警告位置是
crc_16 = 0x0000;

使用原程序为 unsigned int crc_16;
crc_16 = 0x0000;
请问能看出怎么改吗?

...全文
2050 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
tsummer2010 2011-12-25
  • 打赏
  • 举报
回复
高手能具体点嘛?我知道那句话报错了,但不知道怎么改。
如下:
static
FRESULT create_name
(
DIR *dj, /* Pointer to the directory object */
const TCHAR **path /* Pointer to pointer to the segment in the path string */
)
{
#ifdef _EXCVT
static const BYTE excvt[] = _EXCVT; /* Upper conversion table for extended chars */
#endif

#if _USE_LFN /* LFN configuration */
BYTE b, cf;
WCHAR w, *lfn;
UINT i, ni, si, di;
const TCHAR *p;

/* Create LFN in Unicode */
for (p = *path; *p == '/' || *p == '\\'; p++) ; /* Strip duplicated separator */
lfn = dj->lfn;
si = di = 0;
for (;;)
{
w = p[si++]; /* Get a character */
if (w < ' ' || w == '/' || w == '\\') break; /* Break on end of segment */
if (di >= _MAX_LFN) /* Reject too long name */
return FR_INVALID_NAME;
#if !_LFN_UNICODE
w &= 0xFF;
if (IsDBCS1(w))
{ /* Check if it is a DBC 1st byte (always false on SBCS cfg) */
b = (BYTE)p[si++]; /* Get 2nd byte */
if (!IsDBCS2(b))
{
return FR_INVALID_NAME; /* Reject invalid sequence */
}
w =(w << 8) + b; /* Create a DBC */
}
w = ff_convert(w, 1); /* Convert ANSI/OEM to Unicode */
if (!w) return FR_INVALID_NAME; /* Reject invalid code */
#endif
if (w < 0x80 && chk_chr("\"*:<>\?|\x7F", w)) /* Reject illegal chars for LFN */
return FR_INVALID_NAME;
lfn[di++] = w; /* Store the Unicode char */
}
*path = &p[si]; /* Return pointer to the next segment */
cf = (w < ' ') ? NS_LAST : 0; /* Set last segment flag if end of path */
#if _FS_RPATH
if ((di == 1 && lfn[di-1] == '.') || /* Is this a dot entry? */
(di == 2 && lfn[di-1] == '.' && lfn[di-2] == '.')) {
lfn[di] = 0;
for (i = 0; i < 11; i++)
dj->fn[i] = (i < di) ? '.' : ' ';
dj->fn[i] = cf | NS_DOT; /* This is a dot entry */
return FR_OK;
}
#endif
while (di) { /* Strip trailing spaces and dots */
w = lfn[di-1];
if (w != ' ' && w != '.') break;
di--;
}
if (!di) return FR_INVALID_NAME; /* Reject nul string */

lfn[di] = 0; /* LFN is created */

/* Create SFN in directory form */
mem_set(dj->fn, ' ', 11);
for (si = 0; lfn[si] == ' ' || lfn[si] == '.'; si++) ; /* Strip leading spaces and dots */
if (si) cf |= NS_LOSS | NS_LFN;
while (di && lfn[di - 1] != '.') di--; /* Find extension (di<=si: no extension) */

b = i = 0; ni = 8;
for (;;) {
w = lfn[si++]; /* Get an LFN char */
if (!w) break; /* Break on end of the LFN */
if (w == ' ' || (w == '.' && si != di)) { /* Remove spaces and dots */
cf |= NS_LOSS | NS_LFN; continue;
}

if (i >= ni || si == di) { /* Extension or end of SFN */
if (ni == 11) { /* Long extension */
cf |= NS_LOSS | NS_LFN; break;
}
if (si != di) cf |= NS_LOSS | NS_LFN; /* Out of 8.3 format */
if (si > di) break; /* No extension */
si = di; i = 8; ni = 11; /* Enter extension section */
b <<= 2; continue;
}

if (w >= 0x80) { /* Non ASCII char */
#ifdef _EXCVT
w = ff_convert(w, 0); /* Unicode -> OEM code */
if (w) w = excvt[w - 0x80]; /* Convert extended char to upper (SBCS) */
#else
w = ff_convert(ff_wtoupper(w), 0); /* Upper converted Unicode -> OEM code */
#endif
cf |= NS_LFN; /* Force create LFN entry */
}

if (_DF1S && w >= 0x100) { /* Double byte char (always false on SBCS cfg) */
if (i >= ni - 1) {
cf |= NS_LOSS | NS_LFN; i = ni; continue;
}
dj->fn[i++] = (BYTE)(w >> 8);
} else { /* Single byte char */
if (!w || chk_chr("+,;=[]", w)) { /* Replace illegal chars for SFN */
w = '_'; cf |= NS_LOSS | NS_LFN;/* Lossy conversion */
} else {
if (IsUpper(w)) { /* ASCII large capital */
b |= 2;
} else {
if (IsLower(w)) { /* ASCII small capital */
b |= 1; w -= 0x20;
}
}
}
}
dj->fn[i++] = (BYTE)w;
}

if (dj->fn[0] == DDE) dj->fn[0] = NDDE; /* If the first char collides with deleted mark, replace it with 0x05 */

if (ni == 8) b <<= 2;
if ((b & 0x0C) == 0x0C || (b & 0x03) == 0x03) /* Create LFN entry when there are composite capitals */
cf |= NS_LFN;
if (!(cf & NS_LFN)) { /* When LFN is in 8.3 format without extended char, NT flags are created */
if ((b & 0x03) == 0x01) cf |= NS_EXT; /* NT flag (Extension has only small capital) */
if ((b & 0x0C) == 0x04) cf |= NS_BODY; /* NT flag (Filename has only small capital) */
}

dj->fn[NS] = cf; /* SFN is created */

return FR_OK;


#else /* Non-LFN configuration */
BYTE b, c, d, *sfn;
UINT ni, si, i;
const char *p;

/* Create file name in directory form */
for (p = *path; *p == '/' || *p == '\\'; p++) ; /* Strip duplicated separator */
sfn = dj->fn;
mem_set(sfn, ' ', 11);
si = i = b = 0; ni = 8;
#if _FS_RPATH
if (p[si] == '.') { /* Is this a dot entry? */
for (;;) {
c = (BYTE)p[si++];
if (c != '.' || si >= 3) break;
sfn[i++] = c;
}
if (c != '/' && c != '\\' && c > ' ') return FR_INVALID_NAME;
*path = &p[si]; /* Return pointer to the next segment */
sfn[NS] = (c <= ' ') ? NS_LAST | NS_DOT : NS_DOT; /* Set last segment flag if end of path */
return FR_OK;
}
#endif
for (;;) {
c = (BYTE)p[si++];
if (c <= ' ' || c == '/' || c == '\\') break; /* Break on end of segment */
if (c == '.' || i >= ni) {
if (ni != 8 || c != '.') return FR_INVALID_NAME;
i = 8; ni = 11;
b <<= 2; continue;
}
if (c >= 0x80) { /* Extended char? */
b |= 3; /* Eliminate NT flag */
#ifdef _EXCVT
c = excvt[c-0x80]; /* Upper conversion (SBCS) */
#else
#if !_DF1S /* ASCII only cfg */
return FR_INVALID_NAME;
#endif
#endif
}
if (IsDBCS1(c)) { /* Check if it is a DBC 1st byte (always false on SBCS cfg) */
d = (BYTE)p[si++]; /* Get 2nd byte */
if (!IsDBCS2(d) || i >= ni - 1) /* Reject invalid DBC */
return FR_INVALID_NAME;
sfn[i++] = c;
sfn[i++] = d;
} else { /* Single byte code */
if (chk_chr("\"*+,:;<=>\?[]|\x7F", c)) /* Reject illegal chrs for SFN */
return FR_INVALID_NAME;
if (IsUpper(c)) { /* ASCII large capital? */
b |= 2;
} else {
if (IsLower(c)) { /* ASCII small capital? */
b |= 1; c -= 0x20;
}
}
sfn[i++] = c;
}
}
*path = &p[si]; /* Return pointer to the next segment */
c = (c <= ' ') ? NS_LAST : 0; /* Set last segment flag if end of path */

if (!i) return FR_INVALID_NAME; /* Reject nul string */
if (sfn[0] == DDE) sfn[0] = NDDE; /* When first char collides with DDE, replace it with 0x05 */

if (ni == 8) b <<= 2;
if ((b & 0x03) == 0x01) c |= NS_EXT; /* NT flag (Name extension has only small capital) */
if ((b & 0x0C) == 0x04) c |= NS_BODY; /* NT flag (Name body has only small capital) */

sfn[NS] = c; /* Store NT flag, File name is created */

return FR_OK;
#endif
}
lingshawu 2011-10-18
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 crysleeper 的回复:]
在警告的语句之前已经return了吧
[/Quote]
没有,用的是unsigned int 函数,在最开始进行的
unsigned int crc_16;
crc_16 = 0x0000;

最终返回 return( crc_16 );
lingshawu 2011-10-18
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 pathuang68 的回复:]
楼主直接写unsigned int crc_16 = 0;试试看。

不过,这怎么可能呢?!
[/Quote]

试了,证明了此法没有作用。。。
CrySleeper 2011-10-18
  • 打赏
  • 举报
回复
在警告的语句之前已经return了吧
luciferisnotsatan 2011-10-18
  • 打赏
  • 举报
回复
没用过,不清楚。
找那个编译器的手册,看看Warning[Pe111]: statement is unreachable这个到底指什么
pathuang68 2011-10-18
  • 打赏
  • 举报
回复
楼主直接写unsigned int crc_16 = 0;试试看。

不过,这怎么可能呢?!

赵4老师 2011-10-18
  • 打赏
  • 举报
回复
偶遇到类似问题都是用
“每次用/*...*/注释掉不同部分再重新编译,直到定位到具体语法出错的位置。”
的方法解决的。

70,022

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧