mtx_init/lock_init and uninitialized struct mtx

2011-02-24 Thread Dmitry Krivenok
Hello Hackers, Is it allowed to call mtx_init on a mutex defined as an auto variable and not initialized explicitly, i.e.: static int foo() { struct mtx m; // Uninitialized auto variable, so it's value is undefined. mtx_init(m, my_mutex, NULL, MTX_DEF); … // Do something ...

Re: mtx_init/lock_init and uninitialized struct mtx

2011-02-24 Thread Matthew Fleming
On Thu, Feb 24, 2011 at 7:47 AM, Dmitry Krivenok krivenok.dmi...@gmail.com wrote: Hello Hackers, Is it allowed to call mtx_init on a mutex defined as an auto variable and not initialized explicitly, i.e.: We recently ran into this problem at $WORK because we turned on the deadc0de checking in

RE: mtx_init/lock_init and uninitialized struct mtx

2011-02-24 Thread Patrick Mahan
-Original Message- From: owner-freebsd-hack...@freebsd.org [mailto:owner-freebsd- hack...@freebsd.org] On Behalf Of Dmitry Krivenok Sent: Thursday, February 24, 2011 7:47 AM To: freebsd-hackers@freebsd.org Subject: mtx_init/lock_init and uninitialized struct mtx Hello Hackers

Re: mtx_init/lock_init and uninitialized struct mtx

2011-02-24 Thread John Baldwin
On Thursday, February 24, 2011 10:47:27 am Dmitry Krivenok wrote: Hello Hackers, Is it allowed to call mtx_init on a mutex defined as an auto variable and not initialized explicitly, i.e.: It does expect you to zero it first. I've considered adding a MTX_NEW flag to disable this check for

Re: mtx_init/lock_init and uninitialized struct mtx

2011-02-24 Thread Dmitry Krivenok
Thanks a lot for your answers! I'll always explicitly zero stack variables before calling actual *_init() functions. Also, it would be great to document this zeroing requirement in a man page for mtx_init() or simply add a comment in the source. Dmitry On Thu, Feb 24, 2011 at 10:02 PM, John