Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1341195

Re: [PATCH v3] sscanf: implement basic character sets

From Rasmus Villemoes <linux@rasmusvillemoes.dk>
Newsgroups linux.kernel
Subject Re: [PATCH v3] sscanf: implement basic character sets
Date 2016-02-24 01:10 +0100
Message-ID <r5vbI-4KX-3@gated-at.bofh.it> (permalink)
References <r5rUt-29C-7@gated-at.bofh.it> <r5tWi-3Ha-17@gated-at.bofh.it>
Organization D03

Show all headers | View raw


On Tue, Feb 23 2016, Rasmus Villemoes <linux@rasmusvillemoes.dk> wrote:

> On that note, it seems that your field width handling is off-by-one.

Sorry about that, it's me who's off-by-one.

Rasmus


> To get rid of the allocation, why not use a small bitmap? Something like
>
> {
>   char *s = (char *)va_arg(args, char *);
>   DECLARE_BITMAP(map, 256) = {0};
>   bool negate = false;
>
>   /* a field width is required, and must provide room for at least a '\0' */
>   if (field_width <= 0)
>     return num;
>

should be

/* a field width is required */
if (field_width < 0)

and

>   while (test_bit((u8)*str, map) && --field_width) {

should be field_width--, exactly as in your code.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v3] sscanf: implement basic character sets Jessica Yu <jeyu@redhat.com> - 2016-02-23 21:40 +0100
  Re: [PATCH v3] sscanf: implement basic character sets Kees Cook <keescook@chromium.org> - 2016-02-23 21:50 +0100
  Re: [PATCH v3] sscanf: implement basic character sets Andrew Morton <akpm@linux-foundation.org> - 2016-02-23 23:10 +0100
    Re: sscanf: implement basic character sets Jessica Yu <jeyu@redhat.com> - 2016-02-24 06:20 +0100
      Re: sscanf: implement basic character sets Andrew Morton <akpm@linux-foundation.org> - 2016-02-24 06:30 +0100
  Re: [PATCH v3] sscanf: implement basic character sets Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2016-02-23 23:50 +0100
    Re: [PATCH v3] sscanf: implement basic character sets Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2016-02-24 01:10 +0100
    Re: sscanf: implement basic character sets Jessica Yu <jeyu@redhat.com> - 2016-02-24 06:50 +0100

csiph-web