aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorJoel Stanley <joel@jms.id.au>2015-07-21 12:53:12 +0930
committerStewart Smith <stewart@linux.vnet.ibm.com>2015-08-13 15:52:33 +1000
commit6bc3d9531e4428d9b5944b1b2edb8f91b95811c3 (patch)
tree6769a9db329abf394d8405ba6725c8f5008c0f96 /hw
parenteff042167b9e10a94b6f036f9a54e23b2978269a (diff)
downloadskiboot-6bc3d9531e4428d9b5944b1b2edb8f91b95811c3.zip
skiboot-6bc3d9531e4428d9b5944b1b2edb8f91b95811c3.tar.gz
skiboot-6bc3d9531e4428d9b5944b1b2edb8f91b95811c3.tar.bz2
fsp/chiptod: Fix initialised variable
If chiptod_adjust_topology returned true, rc would be uninitialised and the message type passed to fsp_mkmsg would be undefined. This also changes chiptod_adjust_topology to return true/false instead of -1 and 0. hw/fsp/fsp-chiptod.c:45:7: error: variable 'rc' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized] if (chiptod_adjust_topology(topo, action) < 0) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ hw/fsp/fsp-chiptod.c:48:50: note: uninitialized use occurs here resp = fsp_mkmsg(FSP_RSP_TOPO_ENABLE_DISABLE | rc, 0); ^~ hw/fsp/fsp-chiptod.c:45:3: note: remove the 'if' if its condition is always true if (chiptod_adjust_topology(topo, action) < 0) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ hw/fsp/fsp-chiptod.c:30:12: note: initialize the variable 'rc' to silence this warning uint8_t rc; ^ = '\0' Signed-off-by: Joel Stanley <joel@jms.id.au> foo Signed-off-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/chiptod.c10
-rw-r--r--hw/fsp/fsp-chiptod.c12
2 files changed, 12 insertions, 10 deletions
diff --git a/hw/chiptod.c b/hw/chiptod.c
index bae4b50..69e05d9 100644
--- a/hw/chiptod.c
+++ b/hw/chiptod.c
@@ -1657,12 +1657,12 @@ static void chiptod_discover_new_backup(enum chiptod_topology topo)
* topology.
*
* Return values:
- * 0 <= Success
- * -1 <= Topology is active and in use.
+ * true <= Success
+ * false <= Topology is active and in use.
*/
-int chiptod_adjust_topology(enum chiptod_topology topo, bool enable)
+bool chiptod_adjust_topology(enum chiptod_topology topo, bool enable)
{
- uint8_t rc = 0;
+ uint8_t rc = true;
/*
* The FSP can only request that the currently inactive topology
* be disabled or enabled. If the requested topology is currently
@@ -1671,7 +1671,7 @@ int chiptod_adjust_topology(enum chiptod_topology topo, bool enable)
*/
lock(&chiptod_lock);
if (topo == current_topology) {
- rc = -1;
+ rc = false;
goto out;
}
diff --git a/hw/fsp/fsp-chiptod.c b/hw/fsp/fsp-chiptod.c
index 69c59c6..fc8125f 100644
--- a/hw/fsp/fsp-chiptod.c
+++ b/hw/fsp/fsp-chiptod.c
@@ -22,12 +22,12 @@
#define FSP_STATUS_TOPO_IN_USE 0xb8 /* topology is in use */
static bool fsp_chiptod_update_topology(uint32_t cmd_sub_mod,
- struct fsp_msg *msg __unused)
+ struct fsp_msg *msg)
{
struct fsp_msg *resp;
enum chiptod_topology topo;
bool action;
- uint8_t rc;
+ uint8_t status;
switch (cmd_sub_mod) {
case FSP_CMD_TOPO_ENABLE_DISABLE:
@@ -42,10 +42,12 @@ static bool fsp_chiptod_update_topology(uint32_t cmd_sub_mod,
action ? "Enable" : "Disable",
topo ? "Secondary" : "Primary");
- if (chiptod_adjust_topology(topo, action) < 0)
- rc = FSP_STATUS_TOPO_IN_USE;
+ if (!chiptod_adjust_topology(topo, action))
+ status = FSP_STATUS_TOPO_IN_USE;
+ else
+ status = 0x00;
- resp = fsp_mkmsg(FSP_RSP_TOPO_ENABLE_DISABLE | rc, 0);
+ resp = fsp_mkmsg(FSP_RSP_TOPO_ENABLE_DISABLE | status, 0);
if (!resp) {
prerror("CHIPTOD: Response allocation failed\n");
return false;