Fix variable shadow warnings in sdbusplus
-Wshadow is useful for subprojects to enable, because it can find bugs
in common variable names (err, r, i, etc). With these changes, projects
can now build sdbusplus with -Wshadow enabled.
The changes fall into a couple buckets. The first is for constructor
variables that match the member variable name. In these cases, "_in" is
appended to the end of the constructor variable name.
The second is a case where the variable "r" was used for return codes
twice. One instance is changed to "ret".
With these changes, projects can compile with -Wshadow enabled without
warnings.
Change-Id: Ia33a6f8306473c616f6278bb848460167e5463ef
Signed-off-by: Ed Tanous <edtanous@google.com>
diff --git a/src/exception.cpp b/src/exception.cpp
index 804fab8..a7a3596 100644
--- a/src/exception.cpp
+++ b/src/exception.cpp
@@ -21,14 +21,16 @@
return EIO;
}
-SdBusError::SdBusError(int error, const char* prefix, SdBusInterface* intf) :
- error(SD_BUS_ERROR_NULL), intf(intf)
+SdBusError::SdBusError(int error_in, const char* prefix,
+ SdBusInterface* intf_in) :
+ error(SD_BUS_ERROR_NULL),
+ intf(intf_in)
{
// We can't check the output of intf->sd_bus_error_set_errno() because
// it returns the input errorcode. We don't want to try and guess
// possible error statuses. Instead, check to see if the error was
// constructed to determine success.
- intf->sd_bus_error_set_errno(&this->error, error);
+ intf->sd_bus_error_set_errno(&this->error, error_in);
if (!intf->sd_bus_error_is_set(&this->error))
{
throw std::runtime_error("Failed to create SdBusError");
@@ -37,13 +39,13 @@
populateMessage(prefix);
}
-SdBusError::SdBusError(sd_bus_error* error, const char* prefix,
- SdBusInterface* intf) :
- error(*error),
- intf(intf)
+SdBusError::SdBusError(sd_bus_error* error_in, const char* prefix,
+ SdBusInterface* intf_in) :
+ error(*error_in),
+ intf(intf_in)
{
// We own the error so remove the caller's reference
- *error = SD_BUS_ERROR_NULL;
+ *error_in = SD_BUS_ERROR_NULL;
populateMessage(prefix);
}