Re: CVS commit: src/sys/fs/puffs

2014-10-05 Thread Alan Barrett

On Sun, 05 Oct 2014, Alistair Crooks wrote:

On Sun, Oct 05, 2014 at 02:13:15PM +, Alan Barrett wrote:

 #ifdef PUFFSDEBUG
 extern int puffsdebug; /* puffs_subr.c */
-#define DPRINTF(x) if (puffsdebug > 0) printf x
-#define DPRINTF_VERBOSE(x) if (puffsdebug > 1) printf x
+#define DPRINTF(x) do { \
+   if (puffsdebug > 0) printf x; \
+   while (/*CONSTCOND*/0)


I think it'd be even more safe to close the block with a '}' before the
while.


Good idea.

--apb (Alan Barrett)


Re: CVS commit: src/sys/fs/puffs

2014-10-05 Thread Alistair Crooks
On Sun, Oct 05, 2014 at 02:13:15PM +, Alan Barrett wrote:
>  #ifdef PUFFSDEBUG
>  extern int puffsdebug; /* puffs_subr.c */
> -#define DPRINTF(x) if (puffsdebug > 0) printf x
> -#define DPRINTF_VERBOSE(x) if (puffsdebug > 1) printf x
> +#define DPRINTF(x) do { \
> + if (puffsdebug > 0) printf x; \
> + while (/*CONSTCOND*/0)

I think it'd be even more safe to close the block with a '}' before the
while.

> +#define DPRINTF_VERBOSE(x) do { \
> + if (puffsdebug > 1) printf x; \
> + while (/*CONSTCOND*/0)

Here too.

>  #else
> -#define DPRINTF(x)
> -#define DPRINTF_VERBOSE(x)
> +#define DPRINTF(x) ((void)0)
> +#define DPRINTF_VERBOSE(x) ((void)0)
>  #endif
>  
>  #define MPTOPUFFSMP(mp) ((struct puffs_mount *)((mp)->mnt_data))

(I must admit, not compile-tested) 

Regards,
Alistair