From: Wolfgang Denk Date: Fri, 14 Mar 2014 17:16:55 +0100 Subject: [U-Boot] [PATCH v3 3/3] cmd:gpt: randomly generate each partition uuid if undefined In-Reply-To: References: <5ef7cdb8df4fb05c3c371e29d7a61e28e1563a68.1394807506.git.p.marczak@samsung.com> <72629ef58556732156fadf26a2a48be85704f224.1393600504.git.p.marczak@samsung.com> Message-ID: <20140314161655.552F838018C@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 Przemyslaw Marczak, In message you wrote: > Changes: > - randomly generate partition uuid if any is undefined > - print info about set/unset/generated uuid > - update doc/README.gpt ... > + int ret = -1; > char *e, *s; > + char uuid_str[37]; Should we not rather use a #defined macro here instead of the magic number 37 ? > - printf("Environmental '%s' not set\n", str); > - return -1; /* env not set */ > + printf("%s ", str); > + gen_rand_uuid_str(uuid_str); > + setenv(s, uuid_str); > + > + e = getenv(s); > + if (e) { > + puts("set to random.\n"); Can we keep the "var not set" part, so the user understands why U-Boot assigns a random ID here? > + } else { > + printf("%s get from environment.\n", str); Make this debug() ? > + puts("Writing GPT:\n"); > + > + ret = gpt_default(blk_dev_desc, argv[4]); > + if (!ret) { > + puts("success!\n"); > + return CMD_RET_SUCCESS; > + } else { > + puts("error!\n"); > return CMD_RET_FAILURE; This code is too verbose - I suggest to turn all these puts() into debug(). > } else { > return CMD_RET_USAGE; > } Please invert the logic so you can bail out early and reduce the indentation level. 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 Work 8 hours, sleep 8 hours; but not the same 8 hours.