Introduce a library routine to package the idiom:
p = xmalloc(b, n);
memcpy(p, b, n);
and use it where possible. The example in traceroute used xzalloc
but it didn't need to.
function old new delta
xmemdup - 32 +32
last_main 834 826 -8
make_device 2321 2311 -10
common_traceroute_main 3698 3685 -13
readtoken1 3182 3168 -14
procps_scan 1222 1206 -16
forkchild 655 638 -17
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/6 up/down: 32/-78) Total: -46 bytes
Signed-off-by: Ron Yorston <rmy@frippery.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Lines are rewrapped when the terminal width changes or line numbers
are enabled/disabled. The current calculation always adds eight to
the line length for a tab whereas it should only add enough to move
to the next tab stop.
This doesn't affect the display of lines, which is handled elsewhere
and gets tab stops right, but it does cause lines to be wrapped at
the wrong position.
Signed-off-by: Ron Yorston <rmy@frippery.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Line numbers are displayed incorrectly on lines that have a search
pattern highlighted. The problem can be fixed by moving the call to
lineno_str in print_found above the while loop that alters the value
of the line pointer. However, a more substantial rewrite results in
savings.
function old new delta
buffer_print 688 697 +9
.rodata 156077 156045 -32
lineno_str 85 - -85
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/1 up/down: 9/-117) Total: -108 bytes
Signed-off-by: Ron Yorston <rmy@frippery.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
The -S flag, to cause long lines to be truncated, was enabled by
FEATURE_LESS_DASHCMD. This is non-obvious and -S is useful even
if the '-' command isn't enabled.
function old new delta
.rodata 156045 156077 +32
packed_usage 30223 30244 +21
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 53/0) Total: 53 bytes
Signed-off-by: Ron Yorston <rmy@frippery.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Since there are now more statements in the if block after the while loop
in list_i2c_busses_and_exit(), there's no need for a label.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Split i2cdump_main() into shorter functions. Simplify the code a bit.
Make block an array of ints so that we can store negative results of
read functions (fixes a bug found by Denys Vlasenko).
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
We should only warn the user about addresses to be skipped if
(mode == DETECT_MODE_AUTO).
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Addresses 0x00-0x02 shouldn't be scanned by default. This patch makes
'first' default to 0x03 and only enables lower addresses if '-a' option
is passed
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
We can't use i2c_set_slave_addr() in i2cdetect, as we have to check for
EBUSY after calling ioctl(I2C_SLAVE) and print 'UU' on busy addresses
instead of bailing-out.
While we're at it: reorder definitions of local vars in i2cdetect_main().
function old new delta
i2cdetect_main 703 744 +41
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 41/0) Total: 41 bytes
text data bss dec hex filename
826097 4164 9584 839845 cd0a5 busybox_old
826145 4164 9584 839893 cd0d5 busybox_unstripped
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Trying to access /dev/i2c/* on every error after opening /dev/i2c-* can
mislead users who e.g. don't have root access. Instead of bailing-out
with "permission denied" we currently print "no such file or directory".
Fix it by trying open("/dev/i2c/%d") only if we got ENOENT.
Upstream i2cdetect tries to get any info it can from /sys and /proc even
when invoked by an unprivileged user, but we don't want to add unnecessary
bloat.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
UTMP is SVID legacy, UTMPX is mandated by POSIX.
Glibc and uClibc have identical layout of UTMP and UTMPX, both of these
libc treat _PATH_UTMPX as _PATH_UTMP so from a user-perspective nothing
changes except the names of the API entrypoints.
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
https://bugs.debian.org/538685
dc requires whitespace between language elements.
We were requiring
1 2 + p
instead of the abbreviated
1 2+p
(for example).
function old new delta
stack_machine 97 126 +29
dc_main 117 79 -38
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 29/-38) Total: -9 bytes
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Some images do not have the default VID offset. The option -O must
be used to attach such images.
Signed-off-by: Micke Prag <micke.prag@telldus.se>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
The --bb options now depends on LONG_OPTS. Omit mentions of --bb from usage
text when LONG_OPTS is disabled.
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
The Required_argument macro is only defined when long options are enabled.
Fixes the following build error:
miscutils/nandwrite.c: In function 'nandwrite_main':
miscutils/nandwrite.c:120:10: error: expected ',' or ';' before 'Required_argument'
Reported-by: Christian Kästner <kaestner at cs.cmu.edu>
Signed-off-by: Baruch Siach <baruch at tkos.co.il>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
some flash partitions can be smaller than the existing BUFSIZE thus write
BUFSIZE will fail with "no space left on device"
Signed-off-by: Jacob Kjaergaard <jacob.kjaergaard@prevas.dk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
function old new delta
buffer_print 71 104 +33
Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This makes "G" (goto end of input) command work as well as
/search_for_nonexistent_string: both will read to EOF now
even from somewhat slow input (such as kernel's "git log").
function old new delta
ndelay_on 35 43 +8
ndelay_off 35 43 +8
read_lines 695 691 -4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 16/-4) Total: 12 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
since mtd-utils 1.4.7, the default behaviour of nanddump is skipbad
(commit 2521d4f1b6b9866a9c89f3c11a4f6a3d763ff1d7)
Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
since mtd-utils 1.4.7, the omit bad block method has been removed.
(cf commit d8b8f780ec3c916f3990e9227d6bfbb22bf42ef8)
Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
In mtd-utils, the bad block options changed in favor of
--bb=[skipbad|padbad|dumpbad] and omitbad has been removed.
This patch add the --bb=skipbad and padbad methods to busybox' nanddump.
padbad is the current default behaviour.
The difference between skipbad and omitbad is this one:
On a 16K block NAND, if the 1st block of mtd0 is bad, we'll have:
nanddump -b -l 16384 /dev/mtd0 | wc -c
0
nanddump --bb=skipbad -l 16384 /dev/mtd0 | wc -c
16384 <- data from 1st good block
Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Default to ascii instead of latin1. Otherwise man pages can be displayed
incorrectly. E.g. bullets show as "<B7>".
Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
function old new delta
man_main 789 844 +55
Signed-off-by: John Spencer <maillist-busybox@barfooze.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
While at it, move applet/config/kbuild bits into wall.c.
(This way, it's more visible that applet is suid'ed).
function old new delta
wall_main 87 138 +51
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Based on patch by Paul B. Henson <henson@acm.org>
function old new delta
static.size_suffixes - 32 +32
ubi_tools_main 1141 1148 +7
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
We set a default path for the directory where pidfiles are create
when FEATURE_PIDFILE is selected. The default has no effect on
applets which must specify a pidfile path on the command line to
run, and it can be overridden by applets which optionally allow
the user to specify the pidfile path.
We also add pidfile write/remove support for klogd, ntpd and watchdog.
For syslogd, we add a missing remove_pidfile() for better cleanup
on daemon exit.
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
commit e4fa7b7 (limit progress bar flicker) made the progress bar
counter unsigned causing i < 0 to never come true.
Signed-off-by: Timo Teräs <timo.teras@iki.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
We use functions from sys/resource.h in misc applets, but don't include
the header. This breaks building with newer glibc versions, so add the
include where needed.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Make dumping read-only partitions work by opening the device
O_RDONLY; otherwise the open() will fail with -EPERM.
Signed-off-by: Matt Reimer <mreimer@sdgsystems.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
unpack_gz_stream_with_info: fix buggy error check
man: fix possible accesses past the end of a string
move seamless uncompression helpers from read_printf.c to open_transformer.c
function old new delta
show_manpage 153 212 +59
unpack_gz_stream_with_info 520 539 +19
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
In some system (e.g. my "strange" device), line_length is not equal xres *
bytes_per_pixel, so we need to use line_length in scr_fix to mmap and draw
rectangle etc.
My "strange" device output this:
bytes_per_pixel: 4
xres: 600, yres: 1024
yoffset: 0, xoffset: 0, line_length: 2432
G.addr: b74da000
Signed-off-by: Yin Kangkai <kangkai.yin@intel.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Rather than dropping the bad block, rx was appending it
to the file.
Signed-off-by: Daniel Fandrich <dan@coneharvesters.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Rather than dropping the dupe, rx was appending it to the file.
Signed-off-by: Dan Fandrich <dan@coneharvesters.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Progress bar updates flicker quite a bit on slow hw / high resolutions
as the background is completely cleared before the new progress bar
position is drawn on top.
Improve it by first drawing the progress bar and then only fill the
remaining rows with the background.
function old new delta
fb_drawprogressbar 444 429 -15
Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>