Multiple functions use a very complex equation employing
division, modulo, and ternary conditionals to perform a
very simple task of finding the minimum of two values.
Replace all those equations with a call to __min() macro.
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
Dictionary print functions (print_valstr, print_valstr_2col,
dcmi_print_strs) are used in various modules and are excessively
complex. One of the reasons is support for loglevel -1, which means
printing to STDOUT. Another reason is support in dcmi_print_strs()
for so called 'horizontal printing' when only strings without
descriptions are printed in one line with separators.
Horizontal printing was in fact broken as dcmi_print_strs() was
always called with loglevel set to LOG_ERR, which resulted in using
lprintf() that adds a '\n' at the end of each printout.
This commit:
* Fixes horizontal printout for dcmi_print_strs();
* Reduces complexity of all three functions by introducing
a macro helper called uprintf() that automatically chooses
either printf() or lprintf() based on the selected loglevel;
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
Several functions were passed a struct ipmi_intf* even though it was
unused. This removes the unused parameters and changes calls and
signatures.
Partially resolvesipmitool/ipmitool#13
Signed-off-by: Vernon Mauery <vernon.mauery@intel.com>
Handle all date/time stamps uniformly, taking in account the host
endianness. Respect the local time zone and the '-Z' option for
all ipmitool commands. Unify the date and time formatting.
Add correct handling of IPMI timestamps 'since system startup'
and for 'unspecified' timestamps.
Partially resolvesipmitool/ipmitool#23
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
Remove all direct comparisons to 'NULL' for pointers.
Replace them with boolean-like 'if (ptr)' and 'if (!ptr)'.
This makes conditions shorter and easier to read.
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
Make code better readable by replacing `if (rsp->ccode > 0)`
and 'if (rsp->ccode != 0)' with just `if (rsp->ccode)` as
rsp->ccode is anyway an unsigned byte and can't be negative.
Also replace 'if (rsp->ccode == 0)' with 'if (!rsp->ccode)'.
All these changes make lines shorter and easier to read as
a non-zero ccode is an indication of some failure, and so !ccode
naturally reads as 'no error'.
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
There are lots of feature test macros like _POSIX_SOURCE,
_BSD_SOURCE, etc. chaotically placed at the beginning of
multiple files without apparent reason, sometime purely
erroneously.
This commit removes them all for the sake of cleaner code.
No new warnings are added due to that at least for gcc 5.4
on Linux with glibc 2.23.
Commit adds macros and #include in order to bring down the number of `warning:
implicit declaration of function 'X' [-Wimplicit-function-declaration]`
warnings.
Currently, interface-management code in the ipmitool does not allow safe
interface re-opening (i.e. closing and opening again). It is because the session
is allocated in the interface setup callback while is freed in the close
callback. So, normal re-opening of the interface, which can be required for
example durng the HPM.1 upgrade, leads to segmentation fault. That's why in the
ipmi_hpmfwupg.c instead of normal closing interface, directly access the
interface data for subsequent re-opening.
Commit for Dmitry Bazhenov
From the ticket:
(v1.8.12) "dcmi power set_limit action <value>" (where <value> is either
"sel_logging" or "power_off") does not actually send the "Set Power Limit"
command (so no change to the power limit policy is made).
This was caused by all atoi(), strtol(), strtoul() calls being replaced. This
patch should fix it.
Commit for Holger Liebig