sysfs: Fix several clang-tidy issues
* cppcoreguidelines-avoid-c-arrays
* cppcoreguidelines-pro-bounds-array-to-pointer-decay
* readability-identifier-naming
```
../sysfs.hpp:45:28: error: do not declare C-style arrays, use std::array<> instead [cppcoreguidelines-avoid-c-arrays,-warnings-as-errors]
static constexpr const char BRIGHTNESS[] = "brightness";
^
/home/andrew/src/openbmc/phosphor-led-sysfs/build/../sysfs.hpp:45:33: error: invalid case style for variable 'BRIGHTNESS' [readability-identifier-naming,-warnings-as-errors]
static constexpr const char BRIGHTNESS[] = "brightness";
^~~~~~~~~~
brightness
/home/andrew/src/openbmc/phosphor-led-sysfs/build/../sysfs.hpp:46:28: error: do not declare C-style arrays, use std::array<> instead [cppcoreguidelines-avoid-c-arrays,-warnings-as-errors]
static constexpr const char MAX_BRIGHTNESS[] = "max_brightness";
^
/home/andrew/src/openbmc/phosphor-led-sysfs/build/../sysfs.hpp:46:33: error: invalid case style for variable 'MAX_BRIGHTNESS' [readability-identifier-naming,-warnings-as-errors]
static constexpr const char MAX_BRIGHTNESS[] = "max_brightness";
^~~~~~~~~~~~~~
maxBrightness
/home/andrew/src/openbmc/phosphor-led-sysfs/build/../sysfs.hpp:47:28: error: do not declare C-style arrays, use std::array<> instead [cppcoreguidelines-avoid-c-arrays,-warnings-as-errors]
static constexpr const char TRIGGER[] = "trigger";
^
/home/andrew/src/openbmc/phosphor-led-sysfs/build/../sysfs.hpp:47:33: error: invalid case style for variable 'TRIGGER' [readability-identifier-naming,-warnings-as-errors]
static constexpr const char TRIGGER[] = "trigger";
^~~~~~~
trigger
/home/andrew/src/openbmc/phosphor-led-sysfs/build/../sysfs.hpp:48:28: error: do not declare C-style arrays, use std::array<> instead [cppcoreguidelines-avoid-c-arrays,-warnings-as-errors]
static constexpr const char DELAY_ON[] = "delay_on";
^
/home/andrew/src/openbmc/phosphor-led-sysfs/build/../sysfs.hpp:48:33: error: invalid case style for variable 'DELAY_ON' [readability-identifier-naming,-warnings-as-errors]
static constexpr const char DELAY_ON[] = "delay_on";
^~~~~~~~
delayOn
/home/andrew/src/openbmc/phosphor-led-sysfs/build/../sysfs.hpp:49:28: error: do not declare C-style arrays, use std::array<> instead [cppcoreguidelines-avoid-c-arrays,-warnings-as-errors]
static constexpr const char DELAY_OFF[] = "delay_off";
^
/home/andrew/src/openbmc/phosphor-led-sysfs/build/../sysfs.hpp:49:33: error: invalid case style for variable 'DELAY_OFF' [readability-identifier-naming,-warnings-as-errors]
static constexpr const char DELAY_OFF[] = "delay_off";
^~~~~~~~~
delayOff
../test/sysfs.cpp:62:46: error: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,-warnings-as-errors]
std::array<const char *, 4> attrs = {BRIGHTNESS, TRIGGER, DELAY_ON, DELAY_OFF};
^
../test/sysfs.cpp:62:58: error: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,-warnings-as-errors]
std::array<const char *, 4> attrs = {BRIGHTNESS, TRIGGER, DELAY_ON, DELAY_OFF};
^
../test/sysfs.cpp:62:67: error: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,-warnings-as-errors]
std::array<const char *, 4> attrs = {BRIGHTNESS, TRIGGER, DELAY_ON, DELAY_OFF};
^
../test/sysfs.cpp:62:77: error: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,-warnings-as-errors]
std::array<const char *, 4> attrs = {BRIGHTNESS, TRIGGER, DELAY_ON, DELAY_OFF};
^
```
Change-Id: I1df5f9b9f6a8c2073a0bc04ea5f88c580e2cb1b9
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
diff --git a/sysfs.cpp b/sysfs.cpp
index 09bbc5d..277710d 100644
--- a/sysfs.cpp
+++ b/sysfs.cpp
@@ -54,47 +54,47 @@
unsigned long SysfsLed::getBrightness()
{
- return getSysfsAttr<unsigned long>(root / BRIGHTNESS);
+ return getSysfsAttr<unsigned long>(root / attrBrightness);
}
void SysfsLed::setBrightness(unsigned long brightness)
{
- setSysfsAttr<unsigned long>(root / BRIGHTNESS, brightness);
+ setSysfsAttr<unsigned long>(root / attrBrightness, brightness);
}
unsigned long SysfsLed::getMaxBrightness()
{
- return getSysfsAttr<unsigned long>(root / MAX_BRIGHTNESS);
+ return getSysfsAttr<unsigned long>(root / attrMaxBrightness);
}
std::string SysfsLed::getTrigger()
{
- return getSysfsAttr<std::string>(root / TRIGGER);
+ return getSysfsAttr<std::string>(root / attrTrigger);
}
void SysfsLed::setTrigger(const std::string& trigger)
{
- setSysfsAttr<std::string>(root / TRIGGER, trigger);
+ setSysfsAttr<std::string>(root / attrTrigger, trigger);
}
unsigned long SysfsLed::getDelayOn()
{
- return getSysfsAttr<unsigned long>(root / DELAY_ON);
+ return getSysfsAttr<unsigned long>(root / attrDelayOn);
}
void SysfsLed::setDelayOn(unsigned long ms)
{
- setSysfsAttr<unsigned long>(root / DELAY_ON, ms);
+ setSysfsAttr<unsigned long>(root / attrDelayOn, ms);
}
unsigned long SysfsLed::getDelayOff()
{
- return getSysfsAttr<unsigned long>(root / DELAY_OFF);
+ return getSysfsAttr<unsigned long>(root / attrDelayOff);
}
void SysfsLed::setDelayOff(unsigned long ms)
{
- setSysfsAttr<unsigned long>(root / DELAY_OFF, ms);
+ setSysfsAttr<unsigned long>(root / attrDelayOff, ms);
}
} // namespace led
} // namespace phosphor