From: Wolfgang Denk Date: Fri, 21 May 2010 21:11:18 +0200 Subject: [U-Boot] [PATCH] Tools: set multiple variable with fw_setenv utility In-Reply-To: <4BF6B724.6090307@denx.de> References: <1274439131-22807-1-git-send-email-sbabic@denx.de> <20100521113841.6243BCCF026@gemini.denx.de> <4BF6A381.7020200@denx.de> <20100521160351.CA8B3E67644@gemini.denx.de> <4BF6B724.6090307@denx.de> Message-ID: <20100521191118.27E25CCF026@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 Stefano, In message <4BF6B724.6090307@denx.de> you wrote: > > > Adding spaces to the variable value? This makes little sense to me. > > It's just a waste of storage space and boot time. > > Well, I can agree with you, however I have already seen this case... I believe you. I have seen stranger things before ;-) > > Why cannot you process each variable when you read it? The we would > > not need any array or list at all. > > There is a reason, please tell me how good it is ;-) > > I thought the code could be used not only as it is, but integrated in an > application linking the required object (only one, fw_env.o). > An application could internally generate a list of pairs variable/values > and needs a function to set them in the u-boot environment. This is the > reason of the int fw_setenv_multiple(fw_env_list *list, int count) > function. No need to use an external file, no need to call fw_setenv as > external process. An application could link fw_env.o and call > fw_setenv_multiple(). > > I agree with you that I can do everything in a single pass if we do not > provide such kind of external interface. Even then you probably can. Actually it may be easier for the aplication, too, when you provide something similar to classic file I/O interface - fw_env_open() would initialize the in-memory copy of the environment data, fw_env_write() could be called repeatedly to set or delete variables, one at a time, and fw_env_close() would finally compute the CRC and write the data out to persistent storage. I guess in most cases such an interface is easier for the appli- cation, too, because it can handle variables as they appear, and it does not need to provide yet another array (with all the size limitations) for intermediate storage. 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 "One planet is all you get."