逻辑错误:'&' 的左操作数是一个垃圾值
我使用 Twitter-OAuth-iPhone 在我的应用程序中同步消息。 iOS4下就没问题了。
升级到iOS5后,选择菜单'产品'> “分析”,并收到一些警告。
在NSData+Base64.m中,警告''&的左操作数'是一个垃圾值'
此处的代码:
if( ixinbuf == 4 ) {
ixinbuf = 0;
outbuf [0] = ( inbuf[0] << 2 ) | ( ( inbuf[1] & 0x30) >> 4 );
outbuf [1] = ( ( inbuf[1] & 0x0F ) << 4 ) | ( ( inbuf[2] & 0x3C ) >> 2 );
outbuf [2] = ( ( inbuf[2] & 0x03 ) << 6 ) | ( inbuf[3] & 0x3F );
for( i = 0; i < ctcharsinbuf; i++ )
[mutableData appendBytes:&outbuf[i] length:1];
}
还有其他错误消息:
抱歉,我是新手,对这些问题没有任何线索。
你能帮我解决一下吗?
非常感谢!
编辑------------
逻辑循环屏幕截图:
删除失效的 ImageShack 链接
感谢任何建议!
I used Twitter-OAuth-iPhone to synchronize the message in my app. It's all right in iOS4.
After upgraded to iOS5, choose menu 'Product' > 'Analyze', and got a few warnings.
In NSData+Base64.m, It's warning 'The left operand of '&' is a garbage value'
Codes here:
if( ixinbuf == 4 ) {
ixinbuf = 0;
outbuf [0] = ( inbuf[0] << 2 ) | ( ( inbuf[1] & 0x30) >> 4 );
outbuf [1] = ( ( inbuf[1] & 0x0F ) << 4 ) | ( ( inbuf[2] & 0x3C ) >> 2 );
outbuf [2] = ( ( inbuf[2] & 0x03 ) << 6 ) | ( inbuf[3] & 0x3F );
for( i = 0; i < ctcharsinbuf; i++ )
[mutableData appendBytes:&outbuf[i] length:1];
}
And there are other error message:
Sorry I am a novice and have no any clue about these problems.
Would you help me fix it please?
Many THANKS!
Edit------------
Logic loop screenshot:
removing dead ImageShack link
Thanks any suggestion!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
通过将 inbuf 初始化为空字符数组来避开它:
sidestep it by initializing inbuf to an empty char array:
哦,非常很好。
Clang 在这里告诉您的是,在某些非常特定的情况下,您可能最终永远不会初始化
inbuf[1]
。我相信对于看起来像这样的输入可能会发生这种情况:这里指出了另一个主要问题 -
inbuf
和outbuf
的大小被交换。应为char inbuf[4], outbuf[3]
,反之则不然。Oh, very nice.
What Clang is telling you here is that, under some very specific circumstances, you may end up never initializing
inbuf[1]
. I believe this might happen for input which looked something like:There's another major issue being pointed out here -- the sizes of
inbuf
andoutbuf
are swapped. Should bechar inbuf[4], outbuf[3]
, not vice versa.您可以添加 if 语句以确保
inbuf[x]
具有某些值,但我不确定它是否是“傻瓜证明”。
You can add a if statement to ensure that the
inbuf[x]
has some value in itI'm not sure though if it's "fool proof".