diff options
author | lbmkplaceholder <placeholder@lbmkplaceholder.com> | 2022-12-21 15:45:17 +0000 |
---|---|---|
committer | lbmkplaceholder <placeholder@lbmkplaceholder.com> | 2022-12-21 15:45:17 +0000 |
commit | 6ebd178f281cea6474e66c88230f833ab0e97827 (patch) | |
tree | ca4641e5d572248aa492ddda2fbbb4a077e48203 /util/nvmutil | |
parent | 04da953c718f84b19e0ba8bb9d238ad9fa4371f4 (diff) |
util/nvmutil: simplified error handling in rhex()
Diffstat (limited to 'util/nvmutil')
-rw-r--r-- | util/nvmutil/nvmutil.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index bbfa7b3d..80d515f7 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -178,11 +178,9 @@ cmd_setmac(const char *strMac) goto invalid_mac_address; byte = o / 3; for (nib = 0; nib < 2; nib++, total += val8) { - if ((val8 = hextonum(strMac[o + nib])) > 15) { - if (errno != 0) - return; + if ((val8 = hextonum(strMac[o + nib])) > 15) goto invalid_mac_address; - } else if ((byte == 0) && (nib == 1)) { + if ((byte == 0) && (nib == 1)) { if (strMac[o + nib] == '?') val8 = (val8 & 0xE) | 2; } @@ -258,12 +256,10 @@ rhex(void) rfd = -1; } if (readFromFile(&rfd, rbuf, "/dev/urandom", O_RDONLY, BUFSIZ) - != BUFSIZ) { - warn("%s", "/dev/urandom"); - return 16; - } + != BUFSIZ) + err(errno, "/dev/urandom"); if (errno != 0) - return 16; + err(errno, "/dev/urandom"); } return rbuf[rindex++] & 0xf; |