Re: your mail, [PATCH] tipar

Jes Sorensen (jes@wildopensource.com)
22 Mar 2002 16:52:01 +0100


Romain Liévin <rlievin@free.fr> writes:

> Hi,
>
> according to various remarks, I improved the source code.
> I submit it again for new comments & suggestions...

Another comment. Your usage of the START macro is kinda
broken. Basically you declare it as #define START(x) but never use the
value, and instead rely on a local scope variable named max being
present.

> +/* ----- global defines -----------------------------------------------
> */
> +
> +#define START(x) { max=jiffies+HZ/(timeout/10); }
> +#define WAIT(x) { \
> + if (time_before((x), jiffies)) return -1; \
> + if (current->need_resched) schedule(); }
> +/* Try to transmit a byte on the specified port (-1 if error). */
> +static int put_ti_parallel(int minor, unsigned char data)
> +{
> + int bit;
> + unsigned long max;
> +
> + for (bit=0; bit<8; bit++) {
> + if (data & 1) {
> + outbyte(2, minor);
> + START(max);

If you really want to use the START macro, you should redefine it as
follows:

#define START(x) { x=jiffies+HZ/(timeout/10); }

One example of where one has to be careful with macros ;(

Jes
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/