assert macro to check null
I have developed a driver which has become unstable. Now when I debug,I find that it is crashing at http://lxr.free-electrons.com/source/kernel/cred.c?v=3.8#L431 get_cred(new); where null is struct cred *new. I think this new might be NULL. Now I plan to add an assert in our macro that deals with creds, like for asserting passed object isn't NULL. Any suggestions as to how I can do that? Regards, Saket Sinha
On Sat, 10 Aug 2013 09:58:10 +0530, Saket Sinha said:
get_cred(new); where null is struct cred *new.
I think this new might be NULL.
Now I plan to add an assert in our macro that deals with creds, like for asserting passed object isn't NULL.
Any suggestions as to how I can do that?
WARN_ON(!new); is probably your best bet.
Actually WARN_ON macro has been defined slightly differently for each Acrhitecture in kernel. Can you specifically point out the definition of macro you have suggested and where it is defined in kernel. Regards, Saket Sinha On Sat, Aug 10, 2013 at 11:05 AM, <Valdis.Kletnieks@vt.edu> wrote:
On Sat, 10 Aug 2013 09:58:10 +0530, Saket Sinha said:
get_cred(new); where null is struct cred *new.
I think this new might be NULL.
Now I plan to add an assert in our macro that deals with creds, like for asserting passed object isn't NULL.
Any suggestions as to how I can do that?
WARN_ON(!new);
is probably your best bet.
On Sat, 10 Aug 2013 11:16:07 +0530, Saket Sinha said:
Actually WARN_ON macro has been defined slightly differently for each Acrhitecture in kernel.
And that matters for the *caller*, why, exactly? (Hint - the vast majority of calls to WARN_ON() are in non-arch code, so it pretty much has to have the same semantics on all architectures, even if the actual macro is different)
Can you specifically point out the definition of macro you have suggested and where it is defined in kernel.
cd /usr/src/linux && find include arch -type f -name '*.h' | xargs egrep 'define.*WARN_ON' If you're on parisc, avr32, s390, powerpc, sh, or blackfin, you'll get the appropriate version in arch/. If you're on anything else, you'll get the version from include/asm-generic/bug.h Not that it matters - you end up using it exactly the same no matter what arch.
- _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
participants (3)
-
apazmd@gmail.com -
Saket Sinha -
Valdis.Kletnieks@vt.edu