|
|
cd37fb |
From 7acf0fad0ca468f33f86084f36251df5baf3dc94 Mon Sep 17 00:00:00 2001
|
|
|
cd37fb |
From: Jakub Hrozek <jakub.hrozek@posteo.se>
|
|
|
cd37fb |
Date: Wed, 26 Sep 2018 21:01:59 +0200
|
|
|
cd37fb |
Subject: [PATCH 5/7] files.c: Init char *name to NULL
|
|
|
cd37fb |
|
|
|
cd37fb |
Merges:
|
|
|
cd37fb |
https://pagure.io/libuser/issue/27
|
|
|
cd37fb |
|
|
|
cd37fb |
This is mostly to silence coverity warnings. "enum lu_entity_type" has
|
|
|
cd37fb |
three values and several places in the code follow logic as:
|
|
|
cd37fb |
|
|
|
cd37fb |
char *name;
|
|
|
cd37fb |
if ent->type == user:
|
|
|
cd37fb |
name = foo()
|
|
|
cd37fb |
if ent->type == group
|
|
|
cd37fb |
name = bar()
|
|
|
cd37fb |
g_assert(name != NULL)
|
|
|
cd37fb |
|
|
|
cd37fb |
it shouldn't be possible for ent->type to be anything else but in the
|
|
|
cd37fb |
odd case it is, initializing name to NULL will ensure that name will be
|
|
|
cd37fb |
still NULL after the code falls through the conditions and at least the
|
|
|
cd37fb |
behaviour is defined.
|
|
|
cd37fb |
---
|
|
|
cd37fb |
modules/files.c | 6 +++---
|
|
|
cd37fb |
1 file changed, 3 insertions(+), 3 deletions(-)
|
|
|
cd37fb |
|
|
|
cd37fb |
diff --git a/modules/files.c b/modules/files.c
|
|
|
cd37fb |
index 6a7787e28112ba07e0fc44f2887ce1d1540af29e..8c2a282b6448bbfb313b5d4f5eeb28b8240bccd5 100644
|
|
|
cd37fb |
--- a/modules/files.c
|
|
|
cd37fb |
+++ b/modules/files.c
|
|
|
cd37fb |
@@ -1501,7 +1501,7 @@ generic_lock(struct lu_module *module, const char *file_suffix, int field,
|
|
|
cd37fb |
struct lu_ent *ent, enum lock_op op, struct lu_error **error)
|
|
|
cd37fb |
{
|
|
|
cd37fb |
struct editing *e;
|
|
|
cd37fb |
- char *value, *new_value, *name;
|
|
|
cd37fb |
+ char *value, *new_value, *name = NULL;
|
|
|
cd37fb |
gboolean commit = FALSE, ret = FALSE;
|
|
|
cd37fb |
|
|
|
cd37fb |
/* Get the name which keys the entries of interest in the file. */
|
|
|
cd37fb |
@@ -1561,7 +1561,7 @@ generic_is_locked(struct lu_module *module, const char *file_suffix,
|
|
|
cd37fb |
int field, struct lu_ent *ent, struct lu_error **error)
|
|
|
cd37fb |
{
|
|
|
cd37fb |
char *filename;
|
|
|
cd37fb |
- char *value, *name;
|
|
|
cd37fb |
+ char *value, *name = NULL;
|
|
|
cd37fb |
int fd;
|
|
|
cd37fb |
gboolean ret = FALSE;
|
|
|
cd37fb |
|
|
|
cd37fb |
@@ -1752,7 +1752,7 @@ generic_setpass(struct lu_module *module, const char *file_suffix, int field,
|
|
|
cd37fb |
struct lu_error **error)
|
|
|
cd37fb |
{
|
|
|
cd37fb |
struct editing *e;
|
|
|
cd37fb |
- char *value, *name;
|
|
|
cd37fb |
+ char *value, *name = NULL;
|
|
|
cd37fb |
gboolean ret = FALSE;
|
|
|
cd37fb |
|
|
|
cd37fb |
/* Get the name of this account. */
|
|
|
cd37fb |
--
|
|
|
cd37fb |
2.14.4
|
|
|
cd37fb |
|