[Rpm-maint] [rpm-software-management/rpm] Make macros::expand_numeric return int64_t (PR #3454)
Panu Matilainen
notifications at github.com
Tue Nov 19 06:55:34 UTC 2024
@pmatilai commented on this pull request.
> if (arg == NULL)
return 0;
auto [ ign, val ] = macros().expand_numeric(arg);
- return val;
+ if (val > INT_MAX) {
+ rpmlog(RPMLOG_WARNING, _("Macro value too big for int: %" PRIu64 " Using %i instead.\n"), val, INT_MAX);
+ res = INT_MAX;
+ } else if (val < INT_MIN) {
+ rpmlog(RPMLOG_WARNING, _("Macro value too small for int: %" PRIu64 " Using %i instead.\n"), val, INT_MIN);
+ res = INT_MIN;
+ } else {
Turns out there's an STL solution for this: https://en.cppreference.com/w/cpp/algorithm/clamp
No point having separate messages for too small and too big, just state that it's outside range.
--
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/pull/3454#pullrequestreview-2444425362
You are receiving this because you are subscribed to this thread.
Message ID: <rpm-software-management/rpm/pull/3454/review/2444425362 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20241118/b2165906/attachment.htm>
More information about the Rpm-maint
mailing list