逻辑错误:'&' 的左操作数是一个垃圾值

发布于 2024-12-11 04:36:42 字数 1190 浏览 0 评论 0原文

我使用 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];
}

还有其他错误消息: error

抱歉,我是新手,对这些问题没有任何线索。
你能帮我解决一下吗?
非常感谢!

编辑------------
逻辑循环屏幕截图:

删除失效的 ImageShack 链接

完整代码:https://github.com/bengotlieb/Twitter-OAuth-iPhone/blob/master/Twitter+OAuth/MGTwitterEngine/NSData+Base64.m

感谢任何建议!

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'
enter image description here

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:
error

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

Full Codes: https://github.com/bengottlieb/Twitter-OAuth-iPhone/blob/master/Twitter+OAuth/MGTwitterEngine/NSData+Base64.m

Thanks any suggestion!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

秋凉 2024-12-18 04:36:42

通过将 inbuf 初始化为空字符数组来避开它:

unsigned char inbuf[4] = {};
unsigned char outbuf[3];

sidestep it by initializing inbuf to an empty char array:

unsigned char inbuf[4] = {};
unsigned char outbuf[3];
美煞众生 2024-12-18 04:36:42

哦,非常很好。

Clang 在这里告诉您的是,在某些非常特定的情况下,您可能最终永远不会初始化 inbuf[1]。我相信对于看起来像这样的输入可能会发生这种情况:

a=

这里指出了另一个主要问题 - inbufoutbuf 的大小被交换。应为 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:

a=

There's another major issue being pointed out here -- the sizes of inbuf and outbuf are swapped. Should be char inbuf[4], outbuf[3], not vice versa.

各空 2024-12-18 04:36:42

您可以添加 if 语句以确保 inbuf[x] 具有某些值,但

if (sizeof(inbuf[1]) > 0x1)
    outbuf [0] = ( inbuf[0] > 4 );
if (sizeof(inbuf[2]) > 0x1)
    outbuf [1] = ( ( inbuf[1] & 0x0F ) > 2 );
if (sizeof(inbuf[3]) > 0x1)
    outbuf [2] = ( ( inbuf[2] & 0x03 ) 

我不确定它是否是“傻瓜证明”。

You can add a if statement to ensure that the inbuf[x] has some value in it

if (sizeof(inbuf[1]) > 0x1)
    outbuf [0] = ( inbuf[0] > 4 );
if (sizeof(inbuf[2]) > 0x1)
    outbuf [1] = ( ( inbuf[1] & 0x0F ) > 2 );
if (sizeof(inbuf[3]) > 0x1)
    outbuf [2] = ( ( inbuf[2] & 0x03 ) 

I'm not sure though if it's "fool proof".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文