Skip to content

Commit

Permalink
drivers/nutdrv_qx_bestups.c: bestups_get_pins_shutdown_mode(): commen…
Browse files Browse the repository at this point in the history
…t the odd conversion, and harden with snprintf_dynamic() [networkupstools#2450]

Signed-off-by: Jim Klimov <[email protected]>
  • Loading branch information
jimklimov committed Jun 2, 2024
1 parent 84404b9 commit 56b9a72
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions drivers/nutdrv_qx_bestups.c
Original file line number Diff line number Diff line change
Expand Up @@ -585,19 +585,12 @@ static int bestups_get_pins_shutdown_mode(item_t *item, char *value, const size_
}
pins_shutdown_mode = (int)l;

#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL
#pragma GCC diagnostic push
#endif
#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
#endif
#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY
#pragma GCC diagnostic ignored "-Wformat-security"
#endif
snprintf(value, valuelen, item->dfl, pins_shutdown_mode);
#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL
#pragma GCC diagnostic pop
#endif
/* NOTE: Mapping table has "%.0f" for R/W of this concept's value,
* meaning zero digits after the decimal point (could as well be
* an int right away?)
* TODO: Someone with the device should check replacement by "%d".
*/
snprintf_dynamic(value, valuelen, item->dfl, "%.0f", (double)pins_shutdown_mode);

/* We were not asked by the user to change the value */
if ((item->qxflags & QX_FLAG_NONUT) && !getval(item->info_type))
Expand Down

0 comments on commit 56b9a72

Please sign in to comment.