[sane-devel] pthread implementation

Michael Cronenworth mike at cchtml.com
Tue May 5 20:50:30 UTC 2009


Hi,

In sanei/sanei_thread.c there's this little tid-bit of code:

DBG( 2, "pthread_create() created thread %ld\n", (SANE_Pid)thread );

"thread" is of type pthread_t, which is an extremely opaque type. You 
won't get a reliable answer by casting it as long and printing it for 
debugging purposes. I'd suggest removing or revising this code.

Also, type defining SANE_Pid as type long and setting pthread_t type 
variables to this type will result in undefined behaviour.

pthread != pid
as
pthread_create() != fork()

Looks like all of sanei_thread.c needs work. I'm working on a patch.

Michael



More information about the sane-devel mailing list