CAI Qian wrote:
Hi,
--- On Thu, 12/11/08, Jiří Paleček<[email protected]> wrote:
From: Jiří Paleček<[email protected]>
Subject: [LTP] [PATCH] revert some changes causing problems, mostly with
pthread_* functions
To: "[email protected]"<[email protected]>
Date: Thursday, December 11, 2008, 6:15 AM
Hello,
I'm sorry to say this, but some changes in the
"Fix Warnings and Badness
v2" patch[1] from October actually create bugs in the
ltp tests. I think
they should be reverted by applying the attached patch.
The problems are of those types:
1) Calling
pthread_create(&th,&newattr, (void
*)&new_thread, (void *)&newsockfd)
is wrong if eg. newsockfd is a variable subsequently
modified by the
parent thread.
2) Calling
pthread_exit((void *)&exit_val);
is wrong if exit_val is a local or thread-local
variable, incl. errno.
I think they should be reverted, because the warning
(conversion
pointer/integer) doesn't mean anything bad in this
context (provided you
use the same type on both sides, eg. the calling thread and
the created
thread) and other solutions just add unnecessary
complexity.
Thanks for pointing out. It is my mistake because I don't see the problem
pop-up when testing those changes.
I admit the problem you mentioned that need to address, but those warnings are
annoying and untidy because they are mixing with real warnings, which may hide
more serious problems. Eliminate warnings generally improve the quality of code.
While I acknowledge the fact that a correct program with warnings is worse than
a correct program without them, I dont think that making quite intrusive
semantics changes is the way to go, especially if there is no real bug.
Probably the easiest way to get rid of warnings regarding pointer <-> integer
conversions, is to launder the value through (u)intptr_t. It is no worse (and
almost no better - you still lose data if you're not careful) than converting
directly, but should get rid of the warning. For an example, see attachment.
Regards
Jiri Palecek
#include <stdint.h>
int main()
{
short i=1;
void* pi=(void*)i;
short j=(short)pi;
short i2=1;
void* pi2=(void*)(intptr_t)i2;
short j2=(short)(intptr_t)pi2;
return j-j2;
}
------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you. Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list