<div dir="ltr">Russel:<div>Thank you a curly bracket was missing. How could I not notice.</div><div>Valdis:</div><div>I shall take your suggestions.</div><div>Mandeep:</div><div>Thank you for that enlighting ideas</div><div>
<br></div><div>Regards,</div><div>Saket Sinha</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jul 15, 2013 at 7:52 PM, <span dir="ltr"><<a href="mailto:Valdis.Kletnieks@vt.edu" target="_blank">Valdis.Kletnieks@vt.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Mon, 15 Jul 2013 17:39:15 +0530, Mandeep Sandhu said:<br>
<br>
> #define push_root() \<br>
> recursive_mutex_lock(&context->id_lock); \<br>
> context->uid = current->fsuid; \<br>
> context->gid = current->fsgid; \<br>
> do { \<br>
> struct cred *new1 = prepare_creds(); \<br>
> //make changes to any member of this structure \<br>
> commit_creds(new1); \<br>
> } while(0);<br>
<br>
</div>Actually, this has 3 problems:<br>
<br>
1) You have a call to mutex_loc() that doesn't get unlocked. This Is Bad.<br>
<br>
2) If you're using the 'do { foo } while (0)' trick, you want to<br>
put the *whole thing* inside the { } (Hint - you can put local variable<br>
definitions inside the curlies as well).<br>
<br>
3) Leave the ; off the 'while (0)' in the macro definition, because:<br>
<br>
> int main()<br>
> {<br>
> printf("in main\n");<br>
> pushme<br>
> return 0;<br>
> }<br>
<br>
Somebody will forget and put a ; after pushme - and in some contexts, the<br>
additional ; will then cause issues.<br>
<br>
</blockquote></div><br></div>