tools: kwbimage: Refactor line parsing and fix error
authorMario Six <mario.six@gdsys.cc>
Wed, 11 Jan 2017 15:00:59 +0000 (16:00 +0100)
committerStefan Roese <sr@denx.de>
Wed, 1 Feb 2017 08:04:11 +0000 (09:04 +0100)
commit4991b4f7f1e55fed161462cefca7fe483fd3e477
tree7f523fa38e7ad321207b638c3980cc1edfa4d41b
parent79066ef8c9d3c56b46e41c290ae0f598a6d1c59f
tools: kwbimage: Refactor line parsing and fix error

The function image_create_config_parse_oneline is pretty complex, and
since more parameters will be added to support secure booting, we
refactor the function to make it more readable.

Also, when a line contained just a keyword without any parameters,
strtok_r returned NULL, which was then indiscriminately fed into atoi,
causing a segfault. To correct this, we add a NULL check before feeding
the extracted token to atoi, and print an error message in case the
token is NULL.

Signed-off-by: Mario Six <mario.six@gdsys.cc>
Reviewed-by: Stefan Roese <sr@denx.de>
Signed-off-by: Stefan Roese <sr@denx.de>
tools/kwbimage.c