On Mon, 15 Jul 2013 17:39:15 +0530, Mandeep Sandhu said: > #define push_root() \ > recursive_mutex_lock(&context->id_lock); \ > context->uid = current->fsuid; \ > context->gid = current->fsgid; \ > do { \ > struct cred *new1 = prepare_creds(); \ > //make changes to any member of this structure \ > commit_creds(new1); \ > } while(0); Actually, this has 3 problems: 1) You have a call to mutex_loc() that doesn't get unlocked. This Is Bad. 2) If you're using the 'do { foo } while (0)' trick, you want to put the *whole thing* inside the { } (Hint - you can put local variable definitions inside the curlies as well). 3) Leave the ; off the 'while (0)' in the macro definition, because: > int main() > { > printf("in main\n"); > pushme > return 0; > } Somebody will forget and put a ; after pushme - and in some contexts, the additional ; will then cause issues.
Attachment:
pgpaAWNjFhNym.pgp
Description: PGP signature
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@xxxxxxxxxxxxxxxxx http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies