[U-Boot] [PATCH 01/11] fw_env.c: Increase max dev path to 32

Wolfgang Denk wd at denx.de
Mon Oct 7 07:47:13 CEST 2013


Dear Tom,

In message <20131006205527.GP15917 at bill-the-cat> you wrote:
> 
> > Do we really need a static size here?  Can we not auto-adjust to the
> > needed size, say by dynamically allocating the buffer?
> 
> Doesn't look like it, without a big change to the parsing code.

I don't think this requires a big change.  Eventually all it takes is
changing the sscanf() call in get_config() to use a format "%ms"
instead of plain "%s"; form the sscanf() man page:

        · An optional 'm' character. This is used with string
          conversions (%s, %c, %[), and relieves the caller of the
          need to allocate a corresponding buffer to hold the input:
          instead, scanf() allocates a buffer of sufficient size, and
          assigns the address of this buffer to the corresponding
          pointer argument, which should be a pointer to a char *
          variable (this variable does not need to be initialized
          before the call). The caller should subsequently free(3)
          this buffer when it is no longer required.

OK, the struct should then of course contain a const char pointer
instead of the buffer itself, but that's also a trivial change.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"An open mind has but one disadvantage: it collects dirt."
                                                    - a saying at RPI


More information about the U-Boot mailing list