kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* assert macro to check null
@ 2013-08-10  4:28 Saket Sinha
  2013-08-10  5:35 ` Valdis.Kletnieks at vt.edu
  2013-08-10 17:16 ` apazmd at gmail.com
  0 siblings, 2 replies; 5+ messages in thread
From: Saket Sinha @ 2013-08-10  4:28 UTC (permalink / raw)
  To: kernelnewbies

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130810/e2788b2f/attachment.html 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* assert macro to check null
  2013-08-10  4:28 assert macro to check null Saket Sinha
@ 2013-08-10  5:35 ` Valdis.Kletnieks at vt.edu
  2013-08-10  5:46   ` Saket Sinha
  2013-08-10 17:16 ` apazmd at gmail.com
  1 sibling, 1 reply; 5+ messages in thread
From: Valdis.Kletnieks at vt.edu @ 2013-08-10  5:35 UTC (permalink / raw)
  To: kernelnewbies

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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 865 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130810/6ddec3c7/attachment.bin 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* assert macro to check null
  2013-08-10  5:35 ` Valdis.Kletnieks at vt.edu
@ 2013-08-10  5:46   ` Saket Sinha
  2013-08-10  6:34     ` Valdis.Kletnieks at vt.edu
  0 siblings, 1 reply; 5+ messages in thread
From: Saket Sinha @ 2013-08-10  5:46 UTC (permalink / raw)
  To: kernelnewbies

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.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130810/8a981c5f/attachment-0001.html 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* assert macro to check null
  2013-08-10  5:46   ` Saket Sinha
@ 2013-08-10  6:34     ` Valdis.Kletnieks at vt.edu
  0 siblings, 0 replies; 5+ messages in thread
From: Valdis.Kletnieks at vt.edu @ 2013-08-10  6:34 UTC (permalink / raw)
  To: kernelnewbies

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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 865 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130810/a3b0cbe1/attachment.bin 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* assert macro to check null
  2013-08-10  4:28 assert macro to check null Saket Sinha
  2013-08-10  5:35 ` Valdis.Kletnieks at vt.edu
@ 2013-08-10 17:16 ` apazmd at gmail.com
  1 sibling, 0 replies; 5+ messages in thread
From: apazmd at gmail.com @ 2013-08-10 17:16 UTC (permalink / raw)
  To: kernelnewbies

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-08-10 17:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-10  4:28 assert macro to check null Saket Sinha
2013-08-10  5:35 ` Valdis.Kletnieks at vt.edu
2013-08-10  5:46   ` Saket Sinha
2013-08-10  6:34     ` Valdis.Kletnieks at vt.edu
2013-08-10 17:16 ` apazmd at gmail.com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).