summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Kardashevskiy <aik@ozlabs.ru>2021-01-27 19:38:12 +1100
committerAlexey Kardashevskiy <aik@ozlabs.ru>2021-02-12 13:46:16 +1100
commit09b201101478e6e1c858fc4ef4f859d88a2b8a49 (patch)
tree63901b0e011789804bc781cb87890f2aeb5d6db5
parent73cb04d7df4eec3ae294e90d85b8b436a9bf1846 (diff)
downloadqemu-SLOF-09b201101478e6e1c858fc4ef4f859d88a2b8a49.tar.gz
libnvram: Compile with -Wextra
-Wextra enables a bunch of rather useful checks which this fixes. Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
-rw-r--r--lib/libnvram/envvar.c13
-rw-r--r--lib/libnvram/nvram.c13
-rw-r--r--lib/libnvram/nvram.h10
3 files changed, 17 insertions, 19 deletions
diff --git a/lib/libnvram/envvar.c b/lib/libnvram/envvar.c
index ee943fc..d413e97 100644
--- a/lib/libnvram/envvar.c
+++ b/lib/libnvram/envvar.c
@@ -46,7 +46,7 @@ static int get_past_env_pos(partition_t part, char *envvar, int evlen)
* @param evlen string length of the envvar parameter
* @return pointer to temporary string containing the value of envvar
*/
-char *nvram_get_env(partition_t part, char *envvar, int evlen)
+char *nvram_get_env(partition_t part, char *envvar, unsigned evlen)
{
static char temp[256+1];
int len, offset;
@@ -100,10 +100,9 @@ static int find_last_envvar(partition_t part)
return -1;
}
-int nvram_add_env(partition_t part, char *envvar, int evlen, char *value, int vallen)
+int nvram_add_env(partition_t part, char *envvar, unsigned evlen, char *value, unsigned vallen)
{
- int freespace, last, len, offset;
- unsigned int i;
+ unsigned i, freespace, last, len, offset;
/* Find offset where we can write */
last = find_last_envvar(part);
@@ -132,7 +131,7 @@ int nvram_add_env(partition_t part, char *envvar, int evlen, char *value, int va
return 0;
}
-int nvram_del_env(partition_t part, char *envvar, int evlen)
+int nvram_del_env(partition_t part, char *envvar, unsigned evlen)
{
int last, current, pos, i;
char *buffer;
@@ -168,10 +167,10 @@ int nvram_del_env(partition_t part, char *envvar, int evlen)
return 0;
}
-int nvram_set_env(partition_t part, char *envvar, int evlen, char *value, int vallen)
+int nvram_set_env(partition_t part, char *envvar, unsigned evlen, char *value, unsigned vallen)
{
char *oldvalue, *buffer;
- int last, current, buffersize, i;
+ unsigned last, current, buffersize, i;
DEBUG("nvram_set_env %lx[%lx]: %p=>%p\n", part.addr, part.len, envvar, value);
diff --git a/lib/libnvram/nvram.c b/lib/libnvram/nvram.c
index 99deb2a..6d145d7 100644
--- a/lib/libnvram/nvram.c
+++ b/lib/libnvram/nvram.c
@@ -163,7 +163,7 @@ nvram_access(uint64_t, 64, qword)
* @return pointer to temporary buffer
*/
-char *get_nvram_buffer(int len)
+char *get_nvram_buffer(unsigned len)
{
if(len>NVRAM_LENGTH)
return NULL;
@@ -271,7 +271,7 @@ static uint8_t calc_partition_header_checksum(int offset)
static int calc_used_nvram_space(void)
{
- int walk, len;
+ unsigned walk, len;
for (walk=0; walk<NVRAM_LENGTH;) {
if(nvram_read_byte(walk) == 0
@@ -319,7 +319,7 @@ static int calc_used_nvram_space(void)
partition_t get_partition(unsigned int type, char *name)
{
partition_t ret={0,-1};
- int walk, len;
+ unsigned walk, len;
DEBUG("get_partition(%i, '%s')\n", type, name);
@@ -416,11 +416,10 @@ int wipe_partition(partition_t partition, int header_only)
}
-static partition_t create_nvram_partition(int type, const char *name, int len)
+static partition_t create_nvram_partition(int type, const char *name, unsigned len)
{
partition_t ret = { 0, 0 };
- int offset, plen;
- unsigned int i;
+ unsigned i, offset, plen;
plen = ALIGN(len+PARTITION_HEADER_SIZE, 16);
@@ -510,7 +509,7 @@ partition_t new_nvram_partition_fs(int type, char *name, int namelen, int len)
int delete_nvram_partition(partition_t partition)
{
- int i;
+ unsigned i;
partition_t free_part;
if(!partition.len || partition.len == -1)
diff --git a/lib/libnvram/nvram.h b/lib/libnvram/nvram.h
index 73fe444..c8aad31 100644
--- a/lib/libnvram/nvram.h
+++ b/lib/libnvram/nvram.h
@@ -47,7 +47,7 @@ nvram_access_proto(uint64_t, qword)
/* nvram.c */
-char *get_nvram_buffer(int len);
+char *get_nvram_buffer(unsigned len);
void free_nvram_buffer(char *buffer);
int nvramlog_printf(const char* fmt, ...);
partition_t get_partition(unsigned int type, char *name);
@@ -67,9 +67,9 @@ void nvram_init(uint32_t store_token, uint32_t fetch_token,
unsigned int get_nvram_size(void);
/* envvar.c */
-char *nvram_get_env(partition_t part, char *envvar, int evlen);
-int nvram_add_env(partition_t part, char *envvar, int evlen, char *value, int vallen);
-int nvram_del_env(partition_t part, char *envvar, int evlen);
-int nvram_set_env(partition_t part, char *envvar, int evlen, char *val, int vlen);
+char *nvram_get_env(partition_t part, char *envvar, unsigned evlen);
+int nvram_add_env(partition_t part, char *envvar, unsigned evlen, char *value, unsigned vallen);
+int nvram_del_env(partition_t part, char *envvar, unsigned evlen);
+int nvram_set_env(partition_t part, char *envvar, unsigned evlen, char *val, unsigned vlen);
#endif