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]
Date:	Fri, 15 Jul 2011 16:46:31 -0700
From:	Joe Perches <joe@...ches.com>
To:	Jason Baron <jbaron@...hat.com>
Cc:	Bart Van Assche <bvanassche@....org>, gregkh@...e.de,
	jim.cromie@...il.com, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 11/11 re-post] dynamic_debug: use a single printk() to
 emit msgs

On Fri, 2011-07-15 at 15:59 -0400, Jason Baron wrote:
> here's Bart's suggestion as re-post. It looks much cleaner to
> me...
[]
> diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
[]
> @@ -422,52 +422,46 @@ static int ddebug_exec_query(char *query_string)
>  	return 0;
>  }
>  
> -static int dynamic_emit_prefix(const struct _ddebug *descriptor)
> +#define PREFIX_SIZE 64
> +#define LEFT(wrote) ((PREFIX_SIZE - wrote) > 0) ? (PREFIX_SIZE - wrote) : 0
> +
> +static char *dynamic_emit_prefix(const struct _ddebug *desc, char *buf)
>  {
> -	char tid[sizeof(int) + sizeof(int)/2 + 4];
> -	char lineno[sizeof(int) + sizeof(int)/2];
> +	int pos = 0;
>  
> -	if (descriptor->flags & _DPRINTK_FLAGS_INCL_TID) {
> +	pos += snprintf(buf + pos, LEFT(pos), "%s", KERN_DEBUG);
> +	if (desc->flags & _DPRINTK_FLAGS_INCL_TID) {
>  		if (in_interrupt())
> -			snprintf(tid, sizeof(tid), "%s", "<intr> ");
> +			pos += snprintf(buf + pos, LEFT(pos), "%s ",
> +						"<intr>");

scnprintf works without using LEFT.
snprintf does as well.

http://lkml.org/lkml/2010/7/23/375


--
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