OSDN Git Service

android-x86/external-toybox.git
9 years agols: Add -Z (Smack) option
Jan Cybulski [Mon, 20 Oct 2014 13:26:12 +0000 (15:26 +0200)]
ls: Add -Z (Smack) option

Option triggers printing security context,
for smack that is file's access smack label.

Change-Id: I9054d9bcfe4d149e8fbfa0831b6ab50165d2bd91
Signed-off-by: Jan Cybulski <j.cybulski@samsung.com>
Signed-off-by: José Bollo <jose.bollo@open.eurogiciel.org>
9 years agoFix truncate prefix bug and add truncate test suite entry.
Rob Landley [Tue, 28 Apr 2015 17:18:17 +0000 (12:18 -0500)]
Fix truncate prefix bug and add truncate test suite entry.

9 years agoAdd prefix support Hyejin Kim asked about.
Rob Landley [Tue, 28 Apr 2015 16:45:13 +0000 (11:45 -0500)]
Add prefix support Hyejin Kim asked about.

9 years agoFix ls -s and -i indentation in -C and -x modes. (Spotted by Jan Cybulski.)
Rob Landley [Mon, 27 Apr 2015 23:56:11 +0000 (18:56 -0500)]
Fix ls -s and -i indentation in -C and -x modes. (Spotted by Jan Cybulski.)

9 years agoPromote hexedit to other.
Rob Landley [Mon, 27 Apr 2015 16:14:46 +0000 (11:14 -0500)]
Promote hexedit to other.

9 years agoSome infrastructure hexedit needs. (Poor man's curses.)
Rob Landley [Mon, 27 Apr 2015 16:13:19 +0000 (11:13 -0500)]
Some infrastructure hexedit needs. (Poor man's curses.)

9 years agoTeach hexedit to actually edit. Add -r option for read only mode.
Rob Landley [Mon, 27 Apr 2015 16:08:40 +0000 (11:08 -0500)]
Teach hexedit to actually edit. Add -r option for read only mode.

9 years agoFix display and cursor control (to respect bottom boundary).
Rob Landley [Sat, 25 Apr 2015 20:52:59 +0000 (15:52 -0500)]
Fix display and cursor control (to respect bottom boundary).

No actual editing yet.

9 years agoToo tired on the flight back from Japan to work on thinky stuff, so...
Rob Landley [Fri, 24 Apr 2015 22:09:51 +0000 (17:09 -0500)]
Too tired on the flight back from Japan to work on thinky stuff, so...

9 years agoBugfix from Hyejin Kim (count=1 shouldn't change name), plus a bounds check.
Rob Landley [Tue, 21 Apr 2015 06:45:07 +0000 (01:45 -0500)]
Bugfix from Hyejin Kim (count=1 shouldn't change name), plus a bounds check.

Test is 'echo "AAA c 1 0 0 2 5 0 0 1" | makedevs' makes AAA not AAA0.

9 years agoSwitch setprop to use TOYBOX_ON_ANDROID and fix getprop include.
Rob Landley [Tue, 21 Apr 2015 01:59:00 +0000 (20:59 -0500)]
Switch setprop to use TOYBOX_ON_ANDROID and fix getprop include.

(I commented out the android-only #include in getprop to do what compile
testing I could, and then forgot to uncomment it.)

9 years agoCleanup getprop, add qstrcmp() to lib for qsort (because posix-2008 broke
Rob Landley [Mon, 20 Apr 2015 02:50:51 +0000 (21:50 -0500)]
Cleanup getprop, add qstrcmp() to lib for qsort (because posix-2008 broke
alphasort), add compile-time probe for config symbol TOYBOX_ON_ANDROID.

9 years agomdev: implement hotplug support.
Isaac Dunham [Sat, 18 Apr 2015 18:25:06 +0000 (18:25 +0000)]
mdev: implement hotplug support.

Use DEVPATH, DEVNAME, MAJOR, MINOR, and SUBSYSTEM instead of
checking the current path and reading .../dev.
While we're here, probe for partitions in block devices.

This uses a very lame check for ACTION (which can be add, remove,
or change): if it is "remove", then unlink the device.

9 years agoRoadmap update, mostly from enh with a few other pending bits mixed in.
Rob Landley [Sun, 19 Apr 2015 05:15:46 +0000 (00:15 -0500)]
Roadmap update, mostly from enh with a few other pending bits mixed in.

9 years agoAndroid getprop and setprop from Elliott Hughes.
Rob Landley [Sun, 19 Apr 2015 01:28:15 +0000 (20:28 -0500)]
Android getprop and setprop from Elliott Hughes.

9 years agoLink against libattr and libsmack.
Xavier Roche [Sat, 18 Apr 2015 01:18:30 +0000 (20:18 -0500)]
Link against libattr and libsmack.

9 years agoFix a trivial typo in www/about.html.
Elliott Hughes [Fri, 17 Apr 2015 07:52:11 +0000 (02:52 -0500)]
Fix a trivial typo in www/about.html.

Sticky shift key...

9 years agoMake toybox --version use the "git describe" info if it's available.
Rob Landley [Fri, 17 Apr 2015 07:46:11 +0000 (02:46 -0500)]
Make toybox --version use the "git describe" info if it's available.

9 years agoterminal_size should use LINES, not ROWS.
Elliott Hughes [Fri, 17 Apr 2015 02:21:02 +0000 (21:21 -0500)]
terminal_size should use LINES, not ROWS.

The shell's pseudo-variable is called LINES. This is true of at least
bash and mksh.

9 years agoShout from the rooftops that pending is not like other directories.
Rob Landley [Fri, 17 Apr 2015 01:10:23 +0000 (20:10 -0500)]
Shout from the rooftops that pending is not like other directories.

9 years agoPut SELINUX in a a menu, and add config option for SMACK.
Rob Landley [Thu, 16 Apr 2015 01:53:00 +0000 (20:53 -0500)]
Put SELINUX in a a menu, and add config option for SMACK.

9 years agoYet more ps work. Still not there yet.
Rob Landley [Wed, 15 Apr 2015 00:37:55 +0000 (19:37 -0500)]
Yet more ps work. Still not there yet.

9 years agounshare: fix -r
Samuel Holland [Sun, 12 Apr 2015 21:00:16 +0000 (16:00 -0500)]
unshare: fix -r

Calling unshare(2) immediately puts us in the new namespace
with the "overflow" user and group ID. By calling geteuid()
and getegid() in handle_r() after calling unshare(), we try
to map that to root, which Linux refuses to let us do.

What we really want to map to root is the caller's uid/gid
in the original namespace. So we have to save them before
calling unshare().

9 years agoBefore trying to remount read only, see if block device responds to "become rw"
Rob Landley [Sun, 12 Apr 2015 11:17:11 +0000 (06:17 -0500)]
Before trying to remount read only, see if block device responds to "become rw"
ioctl(). (This is a thing Android's old mount already does.)

9 years agoImplement Android restorecon.
Elliott Hughes [Tue, 7 Apr 2015 21:07:46 +0000 (14:07 -0700)]
Implement Android restorecon.

On Android, much of the restorecon logic is in libselinux, so this
isn't portable. We do want to be able to build on the host for
testing *other* toys, though, so #if keeps this building.

Change-Id: Ida5a6713a926140c549d5770d62798f4aedca748

9 years agoFix load_policy error reporting.
Elliott Hughes [Tue, 7 Apr 2015 20:11:55 +0000 (13:11 -0700)]
Fix load_policy error reporting.

Also switch to xopen for O_CLOEXEC paranoia and to avoid a conditional.

Change-Id: Iee5c4c124bcac800313f586768ffcaade542bd22

9 years agogetenforce takes no arguments.
Elliott Hughes [Tue, 7 Apr 2015 20:08:51 +0000 (13:08 -0700)]
getenforce takes no arguments.

Change-Id: Icbee1df8b316039c68ef326f9d4d80f32c603b21

9 years agosetenforce takes exactly one argument.
Elliott Hughes [Tue, 7 Apr 2015 20:07:47 +0000 (13:07 -0700)]
setenforce takes exactly one argument.

Change-Id: I83c478ea9ddd456c61e3f0f99506a1028a7027a1

9 years agoMake more(1) usable.
Elliott Hughes [Fri, 10 Apr 2015 22:04:28 +0000 (17:04 -0500)]
Make more(1) usable.

> Yes, I know, "don't use pending". Sadly, more(1) is pretty useless
> without this. It gets confused by long lines or tabs.
>
> This patch also adds the missing prompt between multiple files.

actually, it looks like we're already hard-coding some escape
sequences? more(1) doesn't need anything that isn't in ANSI, so here's
an alternative patch that fixes the same bugs as the other patch but
also has a reverse-video prompt:

9 years agoUpdate www/roadmap.html with Android progress.
Elliott Hughes [Fri, 10 Apr 2015 21:57:54 +0000 (16:57 -0500)]
Update www/roadmap.html with Android progress.

Not much progress this week. Just route and umount.

Also remove a stray reference to load_policy which already switched.

Also remove an outdated claim that Android logging is done in the
kernel. It's been in userspace for a while now.

9 years agoTweak .gitignore.
Rob Landley [Fri, 10 Apr 2015 05:14:56 +0000 (00:14 -0500)]
Tweak .gitignore.

9 years agoTweak README
Rob Landley [Tue, 7 Apr 2015 19:59:32 +0000 (14:59 -0500)]
Tweak README

9 years agoUpdate multiplexer help text for --version
Rob Landley [Tue, 7 Apr 2015 19:57:55 +0000 (14:57 -0500)]
Update multiplexer help text for --version

9 years agoRevert last mdev commit because it copied code out of a GPLv2 program.
Rob Landley [Wed, 8 Apr 2015 09:20:31 +0000 (04:20 -0500)]
Revert last mdev commit because it copied code out of a GPLv2 program.

Guys, you CANNOT COPY CODE FROM BUSYBOX. I don't care if I was the initial
author of that file, other people have touched it since.

I know I added "pending" because I couldn't keep up with code review in
realtime and stuff was getting lost, so we needed a place to park things
before they underwent the full dorodango process. I also know none of the
binaries I distribute has anything in pending enabled. But dude, if I'm going
to find stuff like this I have to start reviewing the code BEFORE applying
it to pending, and we all know where that leads.

Please don't do this again.

9 years agoAdding --version broke ./toybox command list. (Oops.)
Rob Landley [Tue, 7 Apr 2015 16:54:36 +0000 (11:54 -0500)]
Adding --version broke ./toybox command list. (Oops.)

9 years agoAnnounce switch to git.
Rob Landley [Mon, 6 Apr 2015 01:00:33 +0000 (20:00 -0500)]
Announce switch to git.

9 years agoAdd --version to multiplexer.
Rob Landley [Mon, 6 Apr 2015 00:23:36 +0000 (19:23 -0500)]
Add --version to multiplexer.

Can't think of a better place to stick the actual version info than a #define
at the top of main. Makefile and toys.h are equally awkward, querying git
tags wouldn't work if building a release tarball... watch me forget to update
this when cutting a release.

9 years agoBite the bullet and switch over to git.
Rob Landley [Mon, 6 Apr 2015 00:21:39 +0000 (19:21 -0500)]
Bite the bullet and switch over to git.

9 years agoTo ensure that toybox can be installed alongside busybox without
Paul Barker [Sat, 4 Apr 2015 16:58:06 +0000 (11:58 -0500)]
To ensure that toybox can be installed alongside busybox without
confusing update-alternatives, the paths of the links installed by toybox should
match those installed by busybox. This is accomplished by changing the flags
of a few tools within toybox.

9 years agoAnother in-progress ps snapshot.
Rob Landley [Sat, 4 Apr 2015 06:26:58 +0000 (01:26 -0500)]
Another in-progress ps snapshot.

9 years agoAdd readfileat() to lib
Rob Landley [Fri, 3 Apr 2015 16:49:31 +0000 (11:49 -0500)]
Add readfileat() to lib

9 years agops checkpoint du jour. Does not work yet.
Rob Landley [Fri, 3 Apr 2015 16:46:44 +0000 (11:46 -0500)]
ps checkpoint du jour. Does not work yet.

9 years agoRedoing ps from scratch. Random checkpoint that probably doesn't even compile.
Rob Landley [Thu, 2 Apr 2015 20:07:36 +0000 (15:07 -0500)]
Redoing ps from scratch. Random checkpoint that probably doesn't even compile.

Checking in a stopping point where I figured out what I did wrong, before changing it.

9 years agoAdd head test for -123.
Rob Landley [Sun, 29 Mar 2015 17:03:46 +0000 (12:03 -0500)]
Add head test for -123.

9 years agoFix head bug pointed out by felix janda (recent -123 code broke first file argument...
Rob Landley [Sun, 29 Mar 2015 17:01:30 +0000 (12:01 -0500)]
Fix head bug pointed out by felix janda (recent -123 code broke first file argument of -n).

9 years agoFix sed bug David Halls hit trying to compile libiconv.
Rob Landley [Sun, 29 Mar 2015 01:21:03 +0000 (20:21 -0500)]
Fix sed bug David Halls hit trying to compile libiconv.

9 years agoFix printf bug (%.s should be %.0s not %s) reported by Isabella Parakiss.
Rob Landley [Sat, 28 Mar 2015 18:22:27 +0000 (13:22 -0500)]
Fix printf bug (%.s should be %.0s not %s) reported by Isabella Parakiss.

9 years agoFix an obvious typo in Makefile.
Elliott Hughes [Sat, 28 Mar 2015 18:13:42 +0000 (13:13 -0500)]
Fix an obvious typo in Makefile.

9 years agoupdate the Android section of roadmap.html
Elliott Hughes [Sat, 28 Mar 2015 07:53:08 +0000 (02:53 -0500)]
update the Android section of roadmap.html

Four obsolete tools were removed from Android, and runcon moved to toybox.

9 years agoPromote setenforce to android.
Rob Landley [Sat, 28 Mar 2015 03:03:13 +0000 (22:03 -0500)]
Promote setenforce to android.

9 years agoCleanup setenforce.
Rob Landley [Sat, 28 Mar 2015 03:00:17 +0000 (22:00 -0500)]
Cleanup setenforce.

9 years agoPromote getenforce.
Rob Landley [Sat, 28 Mar 2015 02:54:58 +0000 (21:54 -0500)]
Promote getenforce.

9 years agoCleanup getenforce.
Rob Landley [Sat, 28 Mar 2015 02:52:24 +0000 (21:52 -0500)]
Cleanup getenforce.

9 years agoFlag to make llvm shut up about a broken warning.
Rob Landley [Sat, 28 Mar 2015 02:41:14 +0000 (21:41 -0500)]
Flag to make llvm shut up about a broken warning.

9 years agotail: add old -123 support and comment out #-f until it's actually implemented.
Rob Landley [Sat, 28 Mar 2015 02:25:44 +0000 (21:25 -0500)]
tail: add old -123 support and comment out #-f until it's actually implemented.

9 years agoPromote load_policy to android.
Rob Landley [Sat, 28 Mar 2015 01:50:28 +0000 (20:50 -0500)]
Promote load_policy to android.

9 years agoMinor cleanup of load_policy.
Rob Landley [Sat, 28 Mar 2015 01:48:12 +0000 (20:48 -0500)]
Minor cleanup of load_policy.

9 years agoExplain the craptacular nature of kconfig, and the plan to replace it.
Rob Landley [Thu, 26 Mar 2015 18:25:20 +0000 (13:25 -0500)]
Explain the craptacular nature of kconfig, and the plan to replace it.

9 years agoFix toybox build with C99 compilers
Bernhard Rosenkr?nzer [Wed, 25 Mar 2015 18:46:34 +0000 (13:46 -0500)]
Fix toybox build with C99 compilers

toybox "make menuconfig" currently fails to build if the compiler is in C99
mode (clang 3.6 and gcc 5.0 snapshots default to C99 mode, you can also
reproduce the failure with older gcc by using 'make menuconfig HOSTCC="gcc
-std=gnu99"').

The problem is that inline semantics changed in C99, and kconf_id_lookup's
inline-ness depends on C89 semantics there.

9 years agoImplement load_policy.
Elliott Hughes [Tue, 24 Mar 2015 19:17:03 +0000 (14:17 -0500)]
Implement load_policy.

Note that this is a case where Android's tool isn't the same as the
usual tool. Ours takes an explicit file containing the policy to be
loaded. restorecon is at least command-line compatible, but the
implementation is all in Android's libselinux where there's a
selinux_android_restorecon function.

9 years agoPromote runcon to android (and add an android menu).
Rob Landley [Mon, 23 Mar 2015 18:45:47 +0000 (13:45 -0500)]
Promote runcon to android (and add an android menu).

9 years agoTrivial runcon cleanups.
Rob Landley [Mon, 23 Mar 2015 18:09:48 +0000 (13:09 -0500)]
Trivial runcon cleanups.

9 years agoAdd runcon(1).
Elliott Hughes [Mon, 23 Mar 2015 17:46:20 +0000 (12:46 -0500)]
Add runcon(1).

9 years agoadd missing space in dd output
Elliott Hughes [Mon, 23 Mar 2015 17:39:05 +0000 (12:39 -0500)]
add missing space in dd output

Also, coreutils says "s" instead of "seconds". POSIX specifies the
format of the previous two lines, but doesn't even mention this line.

9 years agoTweak of Elliott Hughes's fix for an off by one error in human_readable
Rob Landley [Mon, 23 Mar 2015 16:49:58 +0000 (11:49 -0500)]
Tweak of Elliott Hughes's fix for an off by one error in human_readable
(137 returned "137 KB".)

9 years agoUpdate the Android section of the roadmap.
Elliott Hughes [Mon, 23 Mar 2015 16:44:56 +0000 (11:44 -0500)]
Update the Android section of the roadmap.

I've removed the reference to fs_mgr, since that's really part of vold
rather than a subset of mount(1), and I've removed the reference to
ifconfig because we're already using the toybox ifconfig and the
reference in this document to the Android command that it referred to
(netcfg) was already removed.

9 years agoAnother bug from David Halls: find -exec wasn't consuming its argument when it didn...
Rob Landley [Sat, 21 Mar 2015 22:15:09 +0000 (17:15 -0500)]
Another bug from David Halls: find -exec wasn't consuming its argument when it didn't activate.

test: find . -name README -exec echo one '{}' ';' -or -exec echo two '{}' ';'

9 years agoinstall -D bugfix from David Halls.
Rob Landley [Sat, 21 Mar 2015 20:49:38 +0000 (15:49 -0500)]
install -D bugfix from David Halls.

(I tweaked some comment text while I was there.)

9 years agoPatch from David Halls to fix mac/ios portability issue.
Rob Landley [Sat, 21 Mar 2015 20:29:21 +0000 (15:29 -0500)]
Patch from David Halls to fix mac/ios portability issue.

9 years agoAdd -123 support to head (suggested by Elliott Hughes).
Rob Landley [Thu, 19 Mar 2015 18:57:02 +0000 (13:57 -0500)]
Add -123 support to head (suggested by Elliott Hughes).

9 years agomdev : add hotplugin feature
Hyejin Kim [Wed, 18 Mar 2015 21:32:01 +0000 (16:32 -0500)]
mdev : add hotplugin feature

As internal needs, Ranjan Kumar (ranjankumar.bth at gmail.com) added hotplug
feature into mdev.

9 years agoFix mount -a segfault without -O, reported by Janus Troelsen.
Rob Landley [Mon, 16 Mar 2015 18:27:16 +0000 (13:27 -0500)]
Fix mount -a segfault without -O, reported by Janus Troelsen.

9 years agoRename a function to better describe what it does.
Rob Landley [Mon, 16 Mar 2015 18:25:29 +0000 (13:25 -0500)]
Rename a function to better describe what it does.

9 years agoI added error handling code in write_rotate().
Hyejin Kim [Mon, 16 Mar 2015 00:29:15 +0000 (19:29 -0500)]
I added error handling code in write_rotate().
I think that it is better to check tf->logfd before doing
truncate()/write() and getting error.

9 years agoMore ps cleanup, mostly refactoring.
Rob Landley [Sat, 14 Mar 2015 17:34:14 +0000 (12:34 -0500)]
More ps cleanup, mostly refactoring.

9 years agoMinor ps refactoring.
Rob Landley [Sat, 14 Mar 2015 02:33:34 +0000 (21:33 -0500)]
Minor ps refactoring.

9 years agoClean up sort help text.
Rob Landley [Sat, 14 Mar 2015 02:17:33 +0000 (21:17 -0500)]
Clean up sort help text.

Use tabs for option indent and don't have -g show up in menu (TOYBOX_FLOAT is
the decision).

9 years agoSwitch nsenter to default y.
Rob Landley [Thu, 12 Mar 2015 20:34:03 +0000 (15:34 -0500)]
Switch nsenter to default y.

9 years agoImplement shred -u and switch to default y in defconfig.
Rob Landley [Thu, 12 Mar 2015 20:32:50 +0000 (15:32 -0500)]
Implement shred -u and switch to default y in defconfig.

9 years agoRemove cat -v help text debris.
Rob Landley [Thu, 12 Mar 2015 20:16:13 +0000 (15:16 -0500)]
Remove cat -v help text debris.

9 years agoThe time command depends on floating point support.
Rob Landley [Thu, 12 Mar 2015 19:27:36 +0000 (14:27 -0500)]
The time command depends on floating point support.

9 years agoMake find accept numeric uid/gid, and simplify makedevs using the new infrastructure.
Rob Landley [Thu, 12 Mar 2015 19:21:33 +0000 (14:21 -0500)]
Make find accept numeric uid/gid, and simplify makedevs using the new infrastructure.

9 years agoMake install support numeric uid/gids (reported by Kylie McClain).
Rob Landley [Thu, 12 Mar 2015 19:20:10 +0000 (14:20 -0500)]
Make install support numeric uid/gids (reported by Kylie McClain).

9 years agoFactor out xgetgrnamid() and xgetpwnamid() into xwrap.c.
Rob Landley [Thu, 12 Mar 2015 16:11:08 +0000 (11:11 -0500)]
Factor out xgetgrnamid() and xgetpwnamid() into xwrap.c.

9 years agoFix mktemp when TMPDIR is set to empty string, reported by Kylie McClain.
Rob Landley [Thu, 12 Mar 2015 04:05:54 +0000 (23:05 -0500)]
Fix mktemp when TMPDIR is set to empty string, reported by Kylie McClain.

9 years agoAdd -m to mknod
Rob Landley [Tue, 10 Mar 2015 19:37:03 +0000 (14:37 -0500)]
Add -m to mknod

9 years agoUse xsignal() instead of signal().
Rob Landley [Tue, 10 Mar 2015 16:07:28 +0000 (11:07 -0500)]
Use xsignal() instead of signal().

9 years agoFix thinko (don't &toybuf to get scratch space) and add -v option.
Rob Landley [Mon, 9 Mar 2015 20:06:10 +0000 (15:06 -0500)]
Fix thinko (don't &toybuf to get scratch space) and add -v option.

9 years agoUpgrade oneit with -r (restart), -3 (send exiting PID values to child), and signal...
Rob Landley [Mon, 9 Mar 2015 19:52:32 +0000 (14:52 -0500)]
Upgrade oneit with -r (restart), -3 (send exiting PID values to child), and signal handling.

9 years agosed depends on -r to be rightmost flag to simplify the REG_EXTENDED test.
Rob Landley [Fri, 6 Mar 2015 22:50:54 +0000 (16:50 -0600)]
sed depends on -r to be rightmost flag to simplify the REG_EXTENDED test.

(If a flag is 1, you can multiply it by the value you want and get that value
else zero without a branch or conditional assignment.) So move -E one to the
left so FLAG_r is 1 again, and add a [+Er] suffix instead of testing
FLAG_r | FLAG_E in the users.

9 years agoThe "no }" error with find | xargs sed is because toy_init() wasn't blanking the...
Rob Landley [Fri, 6 Mar 2015 21:12:52 +0000 (15:12 -0600)]
The "no }" error with find | xargs sed is because toy_init() wasn't blanking the GLOBALS() block on a recursive call. (How that ever worked...)

9 years agoYank $STRIP from config (and STRIP=no weirdness) and just allow strip to fail.
Rob Landley [Fri, 6 Mar 2015 21:11:38 +0000 (15:11 -0600)]
Yank $STRIP from config (and STRIP=no weirdness) and just allow strip to fail.

9 years agoscripts/mkflags.c : main function need return 0 if normal exit
Hyejin Kim [Wed, 4 Mar 2015 13:29:57 +0000 (07:29 -0600)]
scripts/mkflags.c : main function need return 0 if normal exit

9 years agoQuick cleanup pass on tar.
Rob Landley [Wed, 4 Mar 2015 04:06:55 +0000 (22:06 -0600)]
Quick cleanup pass on tar.

9 years agoOn 64 bit, subtracting two pointers produces a long result. On 32 bit, it's an int...
Rob Landley [Tue, 3 Mar 2015 02:27:50 +0000 (20:27 -0600)]
On 64 bit, subtracting two pointers produces a long result. On 32 bit, it's an int. Even though long _is_ 32 bits on a 32 bit systems, gcc warns about it because reasons.

Also, the warning being that "expects int, but type is wchar_t"... no, type
is not wchar_t. Type is probably long. Specify the ACTUAL TYPE, not the random
typedef alias for it. If the translated type _did_ match, there wouldn't
be a warning! (This is why c89 promoted all arguments to int, precisely
so this wasn't a problem.)

9 years agoFix several printf_format warnings.
Rob Landley [Sun, 1 Mar 2015 22:43:01 +0000 (16:43 -0600)]
Fix several printf_format warnings.

9 years agoOnly switch on printf format warnings for error_exit() and friends when TOYBOX_DEBUG...
Rob Landley [Sun, 1 Mar 2015 22:35:05 +0000 (16:35 -0600)]
Only switch on printf format warnings for error_exit() and friends when TOYBOX_DEBUG enabled.

One again gcc manages to be incompetent about producing warnings. For example,
in bzcat we error_exit() with a message that's an error code fed into an
array of string constants, and apparently dereferencing an array of string
literals doesn't give you a string literal according to -Wformat-security.

Not breaking the code to humor the compiler here, the compiler is wrong.

9 years agolet the compiler check format strings
Elliott Hughes [Sun, 1 Mar 2015 22:16:50 +0000 (16:16 -0600)]
let the compiler check format strings

i'll be AFK for a week, so here's the patch i've been using this
evening to find other format string mistakes. BSD uses __printflike
and takes two arguments instead of hard-coding (1,2), but i figured
that as long as you don't need the generality you'd prefer not to have
it. and it's easy enough to retrofit if we ever do have a formatting
function that takes other arguments.

9 years agofix format problems in tar.c
Elliott Hughes [Sun, 1 Mar 2015 22:11:50 +0000 (16:11 -0600)]
fix format problems in tar.c

%o is unsigned, but off_t is signed.
* takes an int.
an error_msg call was missing an argument.

only one of these is an actual error, but i'd like to fix the others
too so that we (toybox, but if not, then Android) can turn on format
string warnings to prevent future bugs like the stat.c LP32 ones.

9 years agoPatches from Elliott Hughes to fix various printf() format strings.
Rob Landley [Sun, 1 Mar 2015 22:08:51 +0000 (16:08 -0600)]
Patches from Elliott Hughes to fix various printf() format strings.

(Don't specify the space flag when it's the default behavior. The ifconfig
stuff was actual bugs.)