BTW....I forgot to mention the problem got solved. Thanks to your suggestions.
Regards,
Saket Sinha
On Mon, Jul 15, 2013 at 9:38 PM, Saket Sinha <saket.sinha89@xxxxxxxxx> wrote:
Russel:Thank you a curly bracket was missing. How could I not notice.Valdis:I shall take your suggestions.Mandeep:Thank you for that enlighting ideasRegards,Saket SinhaOn Mon, Jul 15, 2013 at 7:52 PM, <Valdis.Kletnieks@xxxxxx> wrote:
On Mon, 15 Jul 2013 17:39:15 +0530, Mandeep Sandhu said:Actually, this has 3 problems:
> #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);
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.
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@xxxxxxxxxxxxxxxxx http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies