summaryrefslogtreecommitdiff
path: root/util/nvmutil
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2022-11-27 09:43:47 +0000
committerLeah Rowe <leah@libreboot.org>2022-11-27 09:43:47 +0000
commite8eee6dd8a9393567330905bcddad2eb4a232e8e (patch)
treec1df535ba1b6bcd5c83f590b9664fbb615032f93 /util/nvmutil
parent342e5abe5e46cf6e45fb4fb75a057b660abb978d (diff)
util/nvmutil: mild refactoring
Diffstat (limited to 'util/nvmutil')
-rw-r--r--util/nvmutil/nvmutil.c52
1 files changed, 26 insertions, 26 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index a9ed5c80..02f62304 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -34,7 +34,7 @@
ssize_t readFromFile(int *fd, uint8_t *buf, const char *path, int flags,
size_t size);
-void setmac(const char *strMac);
+void cmd_setmac(const char *strMac);
uint8_t hextonum(char chs);
void cmd_dump(void);
void showmac(int partnum);
@@ -115,7 +115,7 @@ main(int argc, char *argv[])
if (errno == 0) {
if (strMac != NULL)
- setmac(strMac);
+ cmd_setmac(strMac);
else if (cmd != NULL)
(*cmd)();
@@ -130,27 +130,6 @@ nvmutil_exit:
return errno;
}
-void
-writeGbeFile(int *fd, const char *filename)
-{
- int partnum;
- errno = 0;
-
- if (pwrite((*fd), gbe, SIZE_8KB, 0) == SIZE_8KB)
- close((*fd));
- if (errno != 0)
- return;
-
- for (partnum = 0; partnum < 2; partnum++) {
- if (nvmPartModified[partnum])
- printf("Part %d modified\n", partnum);
- else
- fprintf (stderr,
- "Part %d NOT modified\n", partnum);
- }
- printf("File `%s` successfully modified\n", filename);
-}
-
ssize_t
readFromFile(int *fd, uint8_t *buf, const char *path, int flags, size_t size)
{
@@ -175,7 +154,7 @@ readFromFile(int *fd, uint8_t *buf, const char *path, int flags, size_t size)
}
void
-setmac(const char *strMac)
+cmd_setmac(const char *strMac)
{
uint8_t o, val8;
uint16_t val16;
@@ -244,9 +223,9 @@ hextonum(char chs)
if (random > 15) {
close(macfd);
free(rmac);
- random = 0;
rmac = NULL;
- } else if (rmac == NULL) {
+ }
+ if (rmac == NULL) {
random = 0;
if ((rmac = (uint8_t *) malloc(12)) == NULL)
err(1, NULL);
@@ -423,3 +402,24 @@ byteswap(uint8_t *byte) {
byte[1] ^= byte[0];
byte[0] ^= byte[1];
}
+
+void
+writeGbeFile(int *fd, const char *filename)
+{
+ int partnum;
+ errno = 0;
+
+ if (pwrite((*fd), gbe, SIZE_8KB, 0) == SIZE_8KB)
+ close((*fd));
+ if (errno != 0)
+ return;
+
+ for (partnum = 0; partnum < 2; partnum++) {
+ if (nvmPartModified[partnum])
+ printf("Part %d modified\n", partnum);
+ else
+ fprintf (stderr,
+ "Part %d NOT modified\n", partnum);
+ }
+ printf("File `%s` successfully modified\n", filename);
+}