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: <20150227141837.0bca29d9a33c5b107a786a7a@linux-foundation.org>
Date:	Fri, 27 Feb 2015 14:18:37 -0800
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Geert Uytterhoeven <geert@...ux-m68k.org>
Cc:	Jonathan Corbet <corbet@....net>,
	Mike Turquette <mturquette@...aro.org>,
	Stephen Boyd <sboyd@...eaurora.org>,
	Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp>,
	linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org,
	Geert Uytterhoeven <geert+renesas@...der.be>
Subject: Re: [PATCH 3/3] lib/vsprintf: Add %pC{,n,r} format specifiers for
 clocks

On Thu, 26 Feb 2015 12:13:03 +0100 Geert Uytterhoeven <geert@...ux-m68k.org> wrote:

> From: Geert Uytterhoeven <geert+renesas@...der.be>
> 
> Add format specifiers for printing struct clk:
>   - '%pC' or '%pCn': name (Common Clock Framework) or address (legacy
>     clock framework) of the clock,
>   - '%pCr': rate of the clock.
> 
> ...
>
> +static noinline_for_stack
> +char *clock(char *buf, char *end, struct clk *clk, struct printf_spec spec,
> +	    const char *fmt)
> +{
> +	if (!clk)
> +		return string(buf, end, NULL, spec);
> +
> +	switch (fmt[1]) {
> +	case 'r':
> +		return number(buf, end, clk_get_rate(clk), spec);
> +
> +	case 'n':
> +	default:
> +#ifdef CONFIG_COMMON_CLK
> +		return string(buf, end, __clk_get_name(clk), spec);
> +#else
> +		spec.base = 16;
> +		spec.field_width = sizeof(unsigned long) * 2 + 2;
> +		spec.flags |= SPECIAL | SMALL | ZEROPAD;
> +		return number(buf, end, (unsigned long)clk, spec);
> +#endif
> +	}
> +}

Seems a bit cruel to teeny systems which don't implement clock.  How does
this look?  Saves 160 bytes in each powerpc build!

static noinline_for_stack
char *clock(char *buf, char *end, struct clk *clk, struct printf_spec spec,
	    const char *fmt)
{
#ifdef CONFIG_HAVE_CLK
	if (clk) {
		switch (fmt[1]) {
		case 'r':
			return number(buf, end, clk_get_rate(clk), spec);

		case 'n':
		default:
#ifdef CONFIG_COMMON_CLK
			return string(buf, end, __clk_get_name(clk), spec);
#else
			spec.base = 16;
			spec.field_width = sizeof(unsigned long) * 2 + 2;
			spec.flags |= SPECIAL | SMALL | ZEROPAD;
			return number(buf, end, (unsigned long)clk, spec);
#endif
		}
	}
#endif	/* CONFIG_HAVE_CLK */

	return string(buf, end, NULL, spec);
}

diff -puN lib/vsprintf.c~lib-vsprintf-add-%pcnr-format-specifiers-for-clocks-fix lib/vsprintf.c
--- a/lib/vsprintf.c~lib-vsprintf-add-%pcnr-format-specifiers-for-clocks-fix
+++ a/lib/vsprintf.c
@@ -1320,24 +1320,27 @@ static noinline_for_stack
 char *clock(char *buf, char *end, struct clk *clk, struct printf_spec spec,
 	    const char *fmt)
 {
-	if (!clk)
-		return string(buf, end, NULL, spec);
+#ifdef CONFIG_HAVE_CLK
+	if (clk) {
+		switch (fmt[1]) {
+		case 'r':
+			return number(buf, end, clk_get_rate(clk), spec);
 
-	switch (fmt[1]) {
-	case 'r':
-		return number(buf, end, clk_get_rate(clk), spec);
-
-	case 'n':
-	default:
-#ifdef CONFIG_COMMON_CLK
-		return string(buf, end, __clk_get_name(clk), spec);
-#else
-		spec.base = 16;
-		spec.field_width = sizeof(unsigned long) * 2 + 2;
-		spec.flags |= SPECIAL | SMALL | ZEROPAD;
-		return number(buf, end, (unsigned long)clk, spec);
-#endif
+		case 'n':
+		default:
+#ifdef CONFIG_COMMON_CLK
+			return string(buf, end, __clk_get_name(clk), spec);
+#else
+			spec.base = 16;
+			spec.field_width = sizeof(unsigned long) * 2 + 2;
+			spec.flags |= SPECIAL | SMALL | ZEROPAD;
+			return number(buf, end, (unsigned long)clk, spec);
+#endif
+		}
 	}
+#endif	/* CONFIG_HAVE_CLK */
+
+	return string(buf, end, NULL, spec);
 }
 
 int kptr_restrict __read_mostly;
_

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