Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1284664
| From | Rasmus Villemoes <linux@rasmusvillemoes.dk> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH] staging: speakup: kobjects.c: fix char argument to %02x |
| Date | 2015-12-06 01:10 +0100 |
| Message-ID | <qCv3R-7XL-19@gated-at.bofh.it> (permalink) |
| Organization | linux.* mail to news gateway |
If char is signed and ch happens to be negative, printing ch with "%02x" will not do as intended (when ch is -19, one will get "ffffffed"). Fix that by masking with 0xff. Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> --- drivers/staging/speakup/kobjects.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/speakup/kobjects.c b/drivers/staging/speakup/kobjects.c index fdfeb42b2b8f..8b88f03e266b 100644 --- a/drivers/staging/speakup/kobjects.c +++ b/drivers/staging/speakup/kobjects.c @@ -567,7 +567,7 @@ ssize_t spk_var_show(struct kobject *kobj, struct kobj_attribute *attr, if (ch >= ' ' && ch < '~') *cp1++ = ch; else - cp1 += sprintf(cp1, "\\x%02x", ch); + cp1 += sprintf(cp1, "\\x%02x", ch & 0xff); } *cp1++ = '"'; *cp1++ = '\n'; -- 2.6.1 -- 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/
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
[PATCH] staging: speakup: kobjects.c: fix char argument to %02x Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2015-12-06 01:10 +0100
Re: [PATCH] staging: speakup: kobjects.c: fix char argument to %02x Joe Perches <joe@perches.com> - 2015-12-06 01:20 +0100
Re: [PATCH] staging: speakup: kobjects.c: fix char argument to %02x Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2015-12-06 01:30 +0100
Re: [PATCH] staging: speakup: kobjects.c: fix char argument to %02x Joe Perches <joe@perches.com> - 2015-12-06 01:30 +0100
csiph-web