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: <1415635817.8868.6.camel@perches.com>
Date:	Mon, 10 Nov 2014 08:10:17 -0800
From:	Joe Perches <joe@...ches.com>
To:	dedekind1@...il.com
Cc:	Tanya Brokhman <tlinder@...eaurora.org>, hujianyang@...wei.com,
	linux-mtd@...ts.infradead.org, linux-arm-msm@...r.kernel.org,
	David Woodhouse <dwmw2@...radead.org>,
	Brian Norris <computersforpeace@...il.com>,
	open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] UBI: Extend UBI layer debug/messaging capabilities -
 cosmetics

On Mon, 2014-11-10 at 15:14 +0200, Artem Bityutskiy wrote:
> On Mon, 2014-11-10 at 14:53 +0200, Tanya Brokhman wrote:
> > On 11/10/2014 2:18 PM, Artem Bityutskiy wrote:
> > > On Sun, 2014-11-09 at 13:06 +0200, Tanya Brokhman wrote:
> > >>
> > >>   /* Normal UBI messages */
> > >>   #define ubi_msg(ubi, fmt, ...) pr_notice("UBI-%d: %s:" fmt "\n", \
> > >> -                                        ubi->ubi_num, __func__, ##__VA_ARGS__)
> > >> +                               (ubi ? ubi->ubi_num : UBI_MAX_DEVICES), \
> > >> +                               __func__, ##__VA_ARGS__)
> > >>   /* UBI warning messages */
> > >>   #define ubi_warn(ubi, fmt, ...) pr_warn("UBI-%d warning: %s: " fmt "\n", \
> > >> -                                       ubi->ubi_num, __func__, ##__VA_ARGS__)
> > >> +                               (ubi ? ubi->ubi_num : UBI_MAX_DEVICES), \
> > >> +                               __func__, ##__VA_ARGS__)
> > >>   /* UBI error messages */
> > >>   #define ubi_err(ubi, fmt, ...) pr_err("UBI-%d error: %s: " fmt "\n", \
> > >> -                                     ubi->ubi_num, __func__, ##__VA_ARGS__)
> > >> +                               (ubi ? ubi->ubi_num : UBI_MAX_DEVICES), \
> > >> +                               __func__, ##__VA_ARGS__)
> > >
> > > Why did you make these changes? It is preferable to not add another 'if'
> > > statement to this macro to handle one or 2 cases - much bloat, little
> > > gain.
> > >
> > > Could we please avoid this?
> > 
> > I just wanted to be on the safe side and prevent this macro being called 
> > with ubi=NULL that may crash the system. If you still prefer the "if" 
> > removed will do.
> 
> On the other hand, these are macros, and this if gets duplicated in many
> places and translate into few additional assembly instructions per
> message.

The thing that will make these uses smaller is to
convert them to functions.

There is a lot of extra duplicated "UBI-%s <msg_type>: "
constant string .text added.

Using a function uses a single copy of each prefix.

The __func__ variable can also be removed.
__builtin_return_address(0) may be substituted to save
a few more bytes per instance.

Something like:

(prototype)
__printf(2, 3)
void ubi_warn(struct ubi *ubi, const char *fmt, ...);

(implementation)
__printf(2, 3)
void ubi_warn(struct ubi *ubi, const char *fmt, ...)
{
	struct va_format vaf;
	va_list args;
	int device;

	va_start(args, format);

	vaf.fmt = format;
	vaf.va = &args;

	if (!ubi)
		device = UBI_MAX_DEVICE;
	else
		device = ubi->ubi_num;

	pr_warn("UBI-%d warning: %pf: %pV",
		device, __builtin_return_address(0), &vaf);

	va_end(args);
}


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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ