All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ivan Gyurdiev <ivg2@cornell.edu>
To: Stephen Smalley <sds@tycho.nsa.gov>
Cc: selinux@tycho.nsa.gov
Subject: Re: [ SEPOL ] [ SEMANAGE ] Debug v3, some database things
Date: Thu, 13 Oct 2005 10:12:54 -0400	[thread overview]
Message-ID: <434E6B66.2000501@cornell.edu> (raw)
In-Reply-To: <1129206873.26188.99.camel@moss-spartans.epoch.ncsc.mil>

[-- Attachment #1: Type: text/plain, Size: 191 bytes --]


> Wrap the definition with 
> do {
>
> } while (0)
>
> and you'll be fine.
>
> That's a widely used trick in the kernel.
>   
Allright, attached fix patch applies on top of the other one.



[-- Attachment #2: resync.fix.diff --]
[-- Type: text/x-patch, Size: 3847 bytes --]

diff -Naur --exclude CVS --exclude VERSION --exclude ChangeLog old/libsemanage/src/database_direct.c new/libsemanage/src/database_direct.c
--- old/libsemanage/src/database_direct.c	2005-10-13 10:05:46.000000000 -0400
+++ new/libsemanage/src/database_direct.c	2005-10-13 10:08:32.000000000 -0400
@@ -263,6 +263,7 @@
 	dbase_direct_t* dbase) {
 
 	dbase->attached = 0;
+	handle = NULL;
 }
 
 static int dbase_direct_add (
diff -Naur --exclude CVS --exclude VERSION --exclude ChangeLog old/libsemanage/src/debug.h new/libsemanage/src/debug.h
--- old/libsemanage/src/debug.h	2005-10-13 10:05:46.000000000 -0400
+++ new/libsemanage/src/debug.h	2005-10-13 10:08:07.000000000 -0400
@@ -32,18 +32,18 @@
 #define STATUS_NODATA 1
 
 #define msg_write(handle_arg, level_arg,                   \
-	          channel_arg, func_arg, ...) {            \
+	          channel_arg, func_arg, ...) do {         \
+	                                                   \
+        if ((handle_arg)->msg_callback) {                  \
+                (handle_arg)->msg_fname = func_arg;        \
+                (handle_arg)->msg_channel = channel_arg;   \
+                (handle_arg)->msg_level = level_arg;       \
                                                            \
-        if (handle_arg->msg_callback) {                    \
-                handle_arg->msg_fname = func_arg;          \
-                handle_arg->msg_channel = channel_arg;     \
-                handle_arg->msg_level = level_arg;         \
-                                                           \
-                handle_arg->msg_callback(                  \
-                        handle_arg->msg_callback_arg,      \
+                (handle_arg)->msg_callback(                \
+                        (handle_arg)->msg_callback_arg,    \
                         handle_arg, __VA_ARGS__);          \
         }                                                  \
-}
+} while(0)
 
 #define ERR(handle, ...) \
 	msg_write(handle, SEMANAGE_MSG_ERR, "libsemanage", \
diff -Naur --exclude CVS --exclude VERSION --exclude ChangeLog old/libsepol/src/debug.h new/libsepol/src/debug.h
--- old/libsepol/src/debug.h	2005-10-13 10:05:46.000000000 -0400
+++ new/libsepol/src/debug.h	2005-10-13 10:09:55.000000000 -0400
@@ -10,18 +10,18 @@
 #define STATUS_NODATA 1
 
 #define msg_write(handle_arg, level_arg,                   \
-		  channel_arg, func_arg, ...) {            \
+		  channel_arg, func_arg, ...) do {         \
                                                            \
-        if (handle_arg->msg_callback) {                    \
-                handle_arg->msg_fname = func_arg;          \
-                handle_arg->msg_channel = channel_arg;     \
-                handle_arg->msg_level = level_arg;         \
+        if ((handle_arg)->msg_callback) {                  \
+                (handle_arg)->msg_fname = func_arg;        \
+                (handle_arg)->msg_channel = channel_arg;   \
+                (handle_arg)->msg_level = level_arg;       \
                                                            \
-                handle_arg->msg_callback(                  \
-                        handle_arg->msg_callback_arg,      \
+                (handle_arg)->msg_callback(                \
+                        (handle_arg)->msg_callback_arg,    \
                         handle_arg, __VA_ARGS__);          \
         }                                                  \
-}
+} while(0)
 
 #define ERR(handle, ...) \
 	msg_write(handle, SEPOL_MSG_ERR, "libsepol", \
@@ -48,7 +48,7 @@
 extern struct sepol_handle sepol_compat_handle;
 
 #define DEBUG(fname, ...) \
-	msg_write((&sepol_compat_handle), SEPOL_MSG_ERR, "libsepol", \
+	msg_write(&sepol_compat_handle, SEPOL_MSG_ERR, "libsepol", \
 	fname, __VA_ARGS__)
 /* End deprecated */
 

  reply	other threads:[~2005-10-13 14:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-12  8:13 [ RESEND ] [ SEMANAGE ] Debugging system Ivan Gyurdiev
2005-10-12 15:52 ` Stephen Smalley
2005-10-12 16:11   ` Ivan Gyurdiev
2005-10-12 16:04     ` Stephen Smalley
2005-10-12 16:43       ` Ivan Gyurdiev
2005-10-13 10:36         ` [ SEPOL ] [ SEMANAGE ] Debug v3, some database things Ivan Gyurdiev
2005-10-13 10:56           ` Ivan Gyurdiev
2005-10-13 12:34             ` Stephen Smalley
2005-10-13 14:12               ` Ivan Gyurdiev [this message]
2005-10-13 17:11           ` Stephen Smalley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=434E6B66.2000501@cornell.edu \
    --to=ivg2@cornell.edu \
    --cc=sds@tycho.nsa.gov \
    --cc=selinux@tycho.nsa.gov \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.