setarch: do not use -1 as array index [cppcheck]

Negative array index does technically work, but looks awkward and
can confuse static analyser such as cppcheck.

[sys-utils/setarch.c:267]: (error) Array index -1 is out of bounds

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
blkid: fix realloc memory leak [cppcheck]

[misc-utils/blkid.c:367]: (error) Common realloc mistake: 'str' nulled but not freed upon failure

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
uuidd: use output redirection which works [checkbashisms]

possible bashism in misc-utils/uuidd.rc line 52 (should be >word 2>&1):
	if pidofproc -p $PIDFILE $DAEMON >& /dev/null ; then

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
include: fix spurious list.h warnings

include/list.h:224:17: warning: ISO C forbids omitting the middle term of a ?: expression [-pedantic]
include/list.h:255:19: warning: ISO C forbids omitting the middle term of a ?: expression [-pedantic]

Compilation warned about that at least 110 times.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
build: fix redundant redeclaration warnings

env.c:24:15: warning: redundant redeclaration of 'environ' [-Wredundant-decls]
su.c:81:15: warning: redundant redeclaration of 'environ' [-Wredundant-decls]

fstab.c:581:14: warning: redundant redeclaration of 'strsignal' [-Wredundant-decls]

kill.h:1:13: note: previous declaration of 'get_pids' was here
kill.c:152:13: warning: redundant redeclaration of 'get_pids' [-Wredundant-decls]

kill.c:142:5: warning: redundant redeclaration of 'main' [-Wredundant-decls]
getopt.c:89:5: warning: redundant redeclaration of 'main' [-Wredundant-decls]

agetty.c:536:15: warning: redundant redeclaration of 'optarg' [-Wredundant-decls]
agetty.c:537:13: warning: redundant redeclaration of 'optind' [-Wredundant-decls]
script.c:161:13: warning: redundant redeclaration of 'optind' [-Wredundant-decls]
wall.c:96:13: warning: redundant redeclaration of 'optind' [-Wredundant-decls]

libmount.h:362:26: note: previous declaration of 'mnt_update_get_fs' was here
libmount.h:454:26: note: previous declaration of 'mnt_context_get_fs' was here
mountP.h:383:26: warning: redundant redeclaration of 'mnt_context_get_fs' [-Wredundant-decls]
mountP.h:398:26: warning: redundant redeclaration of 'mnt_update_get_fs' [-Wredundant-decls]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
build: fix unused parameter warnings

pager.c:203:14: warning: unused parameter 'argc' [-Wunused-parameter]
pager.c:203:26: warning: unused parameter 'argv' [-Wunused-parameter]

randutils.c:108:14: warning: unused parameter 'argc' [-Wunused-parameter]
randutils.c:108:26: warning: unused parameter 'argv' [-Wunused-parameter]

optstr.c:774:37: warning: unused parameter 'optstr' [-Wunused-parameter]
optstr.c:774:51: warning: unused parameter 'value' [-Wunused-parameter]
optstr.c:774:65: warning: unused parameter 'valsz' [-Wunused-parameter]
optstr.c:774:79: warning: unused parameter 'next' [-Wunused-parameter]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
sysfs: fix printf format warnings

sysfs.c:93:3: warning: format '%u' expects argument of type 'unsigned
	int *', but argument 3 has type 'int *' [-Wformat]
sysfs.c:93:3: warning: format '%u' expects argument of type 'unsigned
	int *', but argument 4 has type 'int *' [-Wformat]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
include: fix void pointer arithmetics warnings

all-io.h:18:9: warning: pointer of type 'void *' used in arithmetic [-pedantic]
all-io.h:38:9: warning: pointer of type 'void *' used in arithmetic [-pedantic]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
docs: clean up partx.8 manual

* Remove bold & italic noise.
* Reformat text to be 70 characters wide.
* Use option and option argument highlights consistently.
* Indent option argument list for --nr.
* Squeeze examples where the same is done multiple different ways.
* Use URL and email macros where appropriate.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
eject: inform if CD-ROM drive is not ready

Include file (see linux/cdrom.h lines 395 and 398) suggests ioctl() can
return CDS_NO_INFO and CDS_DRIVE_NOT_READY, which where ignored.  This
commit will tell user what is going on.

The commit will also make eject to crash in ioctl() will return
unexpected value.

Reference: http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob;f=include/linux/cdrom.h;h=dfd7f187c351440d2ffa81050e46ed2602877f73;hb=HEAD
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
wipefs: use symbolic value for markup mode

In case mode value is found to be out of bounds program will crash.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
blkdev: add blkdev_scsi_type_to_name()

Add a function, and necessary symbols, to convert scsi type id's
to name strings.

Reference: http://permalink.gmane.org/gmane.linux.utilities.util-linux-ng/5994
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
lsblk: use blkdev_scsi_type_to_name()

Replace inline version of similar, but less complete, functionality
with the lib/blkdev.c function.  The function will inform if a type is
unknown, which appears as hex string value.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Merge branch '2012wk23' of git://github.com/kerolasa/lelux-utiliteetit

* '2012wk23' of git://github.com/kerolasa/lelux-utiliteetit:
  lsblk: use blkdev_scsi_type_to_name()
  blkdev: add blkdev_scsi_type_to_name()
  wipefs: use symbolic value for markup mode
  eject: inform if CD-ROM drive is not ready
  docs: clean up partx.8 manual
  include: fix void pointer arithmetics warnings
  sysfs: fix printf format warnings
  build: fix unused parameter warnings
  build: fix redundant redeclaration warnings
  include: fix spurious list.h warnings
  uuidd: use output redirection which works [checkbashisms]
  blkid: fix realloc memory leak [cppcheck]
  setarch: do not use -1 as array index [cppcheck]
include/blkdev: cleanup up

Signed-off-by: Karel Zak <kzak@redhat.com>
lsblk: use fallback for TYPE

 ... bug introduced by 1edd8af70b4794c796d0faed0cf763ff3474b92e

Signed-off-by: Karel Zak <kzak@redhat.com>
lib/blkdev: return static strings by blkdev_scsi_type_to_name()

Signed-off-by: Karel Zak <kzak@redhat.com>