[PATCH] soc: qcom: cmd-db: initialize struct to remove warning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The struct isn't initialized, so gcc can't guarantee that the struct
member is initialized thats why it says maybe-uninitialized.

drivers/soc/qcom/cmd-db.c: In function ‘cmd_db_read_addr’:
drivers/soc/qcom/cmd-db.c:194:21: warning: ‘ent.addr’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  return ret < 0 ? 0 : le32_to_cpu(ent.addr);
drivers/soc/qcom/cmd-db.c: In function ‘cmd_db_read_aux_data’:
drivers/soc/qcom/cmd-db.c:221:10: warning: ‘ent.len’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  ent_len = le16_to_cpu(ent.len);
drivers/soc/qcom/cmd-db.c:226:15: warning: ‘*((void *)&rsc_hdr+4)’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  memcpy(data, rsc_offset(&rsc_hdr, &ent), len);
               ^~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/soc/qcom/cmd-db.c:226:15: warning: ‘*((void *)&ent+22)’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  CC      drivers/mfd/pcf50633-irq.o
drivers/soc/qcom/cmd-db.c: In function ‘cmd_db_read_aux_data_len’:
drivers/soc/qcom/cmd-db.c:247:38: warning: ‘ent.len’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  return ret < 0 ? 0 : le16_to_cpu(ent.len);
                                      ^
drivers/soc/qcom/cmd-db.c: In function ‘cmd_db_read_slave_id’:
drivers/soc/qcom/cmd-db.c:269:7: warning: ‘ent.addr’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  addr = le32_to_cpu(ent.addr);

Initialize structs entry_header and rsc_hdr to remove the compile
warning 'maybe-uninitialized'.

Fixes: f22f5914c8c8 ("drivers: qcom: add command DB driver")
Signed-off-by: Anders Roxell <anders.roxell@xxxxxxxxxx>
---
 drivers/soc/qcom/cmd-db.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/soc/qcom/cmd-db.c b/drivers/soc/qcom/cmd-db.c
index a6f646295f06..1663dd1e46da 100644
--- a/drivers/soc/qcom/cmd-db.c
+++ b/drivers/soc/qcom/cmd-db.c
@@ -186,7 +186,7 @@ static int cmd_db_get_header(const char *id, struct entry_header *eh,
 u32 cmd_db_read_addr(const char *id)
 {
 	int ret;
-	struct entry_header ent;
+	struct entry_header ent = {};
 	struct rsc_hdr rsc_hdr;
 
 	ret = cmd_db_get_header(id, &ent, &rsc_hdr);
@@ -207,8 +207,8 @@ EXPORT_SYMBOL(cmd_db_read_addr);
 int cmd_db_read_aux_data(const char *id, u8 *data, size_t len)
 {
 	int ret;
-	struct entry_header ent;
-	struct rsc_hdr rsc_hdr;
+	struct entry_header ent = {};
+	struct rsc_hdr rsc_hdr = {};
 	u16 ent_len;
 
 	if (!data)
@@ -239,7 +239,7 @@ EXPORT_SYMBOL(cmd_db_read_aux_data);
 size_t cmd_db_read_aux_data_len(const char *id)
 {
 	int ret;
-	struct entry_header ent;
+	struct entry_header ent = {};
 	struct rsc_hdr rsc_hdr;
 
 	ret = cmd_db_get_header(id, &ent, &rsc_hdr);
@@ -258,7 +258,7 @@ EXPORT_SYMBOL(cmd_db_read_aux_data_len);
 enum cmd_db_hw_type cmd_db_read_slave_id(const char *id)
 {
 	int ret;
-	struct entry_header ent;
+	struct entry_header ent = {};
 	struct rsc_hdr rsc_hdr;
 	u32 addr;
 
-- 
2.17.0

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [Linux for Sparc]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux