wpa_supplicant: if printf is a macro, #ifdefs inside are not good

Cristian Ionescu-Idbohrn cristian.ionescu-idbohrn
Tue Jan 13 01:02:32 PST 2009


On Tue, 13 Jan 2009, Jouni Malinen wrote:

> On Mon, Jan 12, 2009 at 11:42:09PM +0100, Cristian Ionescu-Idbohrn wrote:
> > I got this patch from one of my knowlegeable colleagues.  Thoughts?
> > Comments?
> >
> > -	printf("%s\n\n%s\n"
> > +	/* Printf can be a macro, but no preprocessor directives are
> > +	   allowed in a macro parameter list.  However, printf is
> > +	   required to also exist as a function, so let's force it to
> > +	   not being recognized as a macro with parameters. */
> > +	(printf)("%s\n\n%s\n"
>
> Is this referring to wpa_supplicant/main.c and the first printf() call
> in usage()? What is so special about that particular printf()? Where is
> the '#ifdef' that is referenced on the Subject line and what is the
> purpose of the printf macro? I have some problems trying to figure out
> what exactly is the issue that this is trying to resolve..

If I understand things correctly, it's the 2:nd and 3:rd printf
in usage:

  47 #ifndef CONFIG_NO_STDOUT_DEBUG
  48         printf("options:\n"
  49                "  -b = optional bridge interface name\n"
  50                "  -B = run daemon in the background\n"
  51                "  -c = Configuration file\n"
  52                "  -C = ctrl_interface parameter (only used if -c is not)\n"
  53                "  -i = interface name\n"
  54                "  -d = increase debugging verbosity (-dd even more)\n"
  55                "  -D = driver name\n"
->56 #ifdef CONFIG_DEBUG_FILE
->57                "  -f = log output to debug file instead of stdout\n"
->58 #endif /* CONFIG_DEBUG_FILE */
  59                "  -g = global ctrl_interface\n"
  60                "  -K = include keys (passwords, etc.) in debug output\n"
  61                "  -t = include timestamp in debug messages\n"
  62                "  -h = show this help text\n"
  63                "  -L = show license (GPL and BSD)\n");
  64         printf("  -p = driver parameters\n"
  65                "  -P = PID file\n"
  66                "  -q = decrease debugging verbosity (-qq even less)\n"
->67 #ifdef CONFIG_CTRL_IFACE_DBUS
->68                "  -u = enable DBus control interface\n"
->69 #endif /* CONFIG_CTRL_IFACE_DBUS */
  70                "  -v = show version\n"
  71                "  -W = wait for a control interface monitor before starting\n"
  72                "  -N = start describing new interface\n");


Cheers,

-- 
Cristian



More information about the Hostap mailing list