From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wolfgang Denk Date: Mon, 07 Oct 2013 07:47:13 +0200 Subject: [U-Boot] [PATCH 01/11] fw_env.c: Increase max dev path to 32 In-Reply-To: <20131006205527.GP15917@bill-the-cat> References: <1380227287-26057-1-git-send-email-trini@ti.com> <1380227287-26057-2-git-send-email-trini@ti.com> <20131005200212.37582380A3C@gemini.denx.de> <20131006205527.GP15917@bill-the-cat> Message-ID: <20131007054713.660F5380435@gemini.denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Tom, In message <20131006205527.GP15917@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