lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20080714161724.GS19302@solarflare.com>
Date:	Mon, 14 Jul 2008 17:17:25 +0100
From:	Ben Hutchings <bhutchings@...arflare.com>
To:	Yevgeny Petrilin <yevgenyp@...lanox.co.il>
Cc:	jeff@...zik.org, netdev@...r.kernel.org,
	Liran Liss <liranl@...lanox.co.il>, tziporet@...lanox.co.il,
	Roland Dreier <rdreier@...co.com>
Subject: Re: [PATCH RFC 01/10] mlx4_en: Include file

Yevgeny Petrilin wrote:
[...]
> +#ifdef CONFIG_MLX4_EN_DEBUG
> +#define mlx4_dbg(mdev, format, arg...)	\
> +	printk(KERN_DEBUG "%s %s: " format , DRV_NAME ,\
> +		(&mdev->pdev->dev)->bus_id , ## arg)
> +#else /* CONFIG_MLX4_DEBUG */
> +#define mlx4_dbg(mdev, format, arg...) do { (void) mdev; } while (0)
> +#endif /* CONFIG_MLX4_DEBUG */
> +
> +#define mlx4_err(mdev, format, arg...) \
> +	printk(KERN_ERR "%s %s: " format , DRV_NAME ,\
> +		(&mdev->pdev->dev)->bus_id , ## arg)
> +#define mlx4_info(mdev, format, arg...) \
> +	printk(KERN_INFO "%s %s: " format , DRV_NAME ,\
> +		(&mdev->pdev->dev)->bus_id , ## arg)
> +#define mlx4_warn(mdev, format, arg...) \
> +	printk(KERN_WARNING "%s %s: " format , DRV_NAME ,\
> +		(&mdev->pdev->dev)->bus_id , ## arg)

I think these should be defined in terms of dev_dbg etc.

[...]
> +#ifdef CONFIG_MLX4_EN_PREFETCH
> +	#define PREFETCH(x)		prefetch(x)
> +#else
> +	#define PREFETCH(x)
> +#endif
> +
> +#ifdef CONFIG_MLX4_EN_SW_COUNTERS
> +#define DO_SW_COUNTERS			1
> +#define SET_SW_COUNTER(cnt, val)	((cnt) = (val))
> +#define INC_SW_COUNTER(cnt)		(++(cnt))
> +#define ADD_SW_COUNTER(cnt, add)	((cnt) += (add))
> +#else
> +#define DO_SW_COUNTERS			0
> +#define SET_SW_COUNTER(cnt, val)
> +#define INC_SW_COUNTER(cnt)
> +#define ADD_SW_COUNTER(cnt, add)
> +#endif

The do-nothing implementations should be do {} while (0).

[...]
> +/*
> + * Useful macros
> + */
> +
> +#define ROUNDUP_LOG2(x)		ilog2(roundup_pow_of_two(x))
> +#define XNOR(x, y)		(!(x) == !(y))
> +#define MIN(a, b)		((a) < (b) ? (a) : (b))
> +#define MAX(a, b)		((a) > (b) ? (a) : (b))

So useful that <linux/kernel.h> already has quite a few of them...

Ben.

-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ