The strtol_or_err() already check argument is not larger than
LONG_MAX. This commit also removes clang warning.
free.c:262:55: warning: comparison of integers of different signs: 'int' and 'unsigned long' [-Wsign-compare]
if (args.repeat_counter < 1 || args.repeat_counter > ULONG_MAX/2)
~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Bug-Debian: http://bugs.debian.org/654368
On systems with very large amonut of RAM when they use the -b or --bytes
option on free you get overflow and free shows a negative amount of
memory, which is obviously wrong.
The handling of the -c (count) option in free uses the standard string
handling and error utils. The program also checks for negative counts
and errors on these.
err and warn are BSD format but they are not recommended by library
developers. However their consiseness is useful!
The solution is to use some macros that create xerr etc which then
just map to the error() function. The next problem is error() uses
program_invocation_name so we set this to program_invovation_short_name
This is a global set but seems to be the convention (or at least errors
are on the short name only) used everywhere else.
Support long options, use program_invocation_short_name, print
version up on request, new giga & tera byte sizes switches, exit
when numeric arguments has garbage... and for rest see the diff.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>