public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 01/12] tests: check /proc availability, and go-around if it is incomplete
@ 2014-05-11 19:26 Sami Kerola
  2014-05-11 19:26 ` [PATCH 02/12] cytune: remove from util-linux Sami Kerola
                   ` (12 more replies)
  0 siblings, 13 replies; 21+ messages in thread
From: Sami Kerola @ 2014-05-11 19:26 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa, Ruediger Meier

Unavailability of /proc is fatal for kill, and continuing with the test
in that case does not make sense as it will only mean false positive
errors.

Where /proc/<pid>/status file(s) does not exist the check will perform
opportunistic sleep with assumption the test_sigreceive will be ready to
be killed if it has some time to init.

CC: Ruediger Meier <sweet_f_a@gmx.de>
Reference: https://travis-ci.org/rudimeier/util-linux/jobs/24561058
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 tests/ts/kill/kill_functions.sh | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/tests/ts/kill/kill_functions.sh b/tests/ts/kill/kill_functions.sh
index 73fff05..a2a2483 100644
--- a/tests/ts/kill/kill_functions.sh
+++ b/tests/ts/kill/kill_functions.sh
@@ -1,3 +1,5 @@
+# kill tests, or command, will not when /proc is missing.
+test /proc || ts_skip "/proc not available"
 
 # unfortunately we are using gawk features
 type gawk >/dev/null 2>&1 || ts_skip "cannot find gawk"
@@ -8,6 +10,17 @@ function check_test_sigreceive {
 	local pid=$1
 
 	for i in 0.01 0.1 1 1 1 1; do
+		if [ ! -f /proc/$pid/status ]; then
+			# The /proc exists, but not status file. Because
+			# the process already started it is unlikely the
+			# file would appear after any amount of waiting.
+			# Try to sleep for moment and hopefully
+			# test_sigreceive is ready to be killed.
+			echo "kill_functions.sh: /proc/$pid/status: No such file or directory"
+			sleep 2
+			rc=1
+			break
+		fi
 		gawk 'BEGIN { retval=1 }
 		/^SigCgt/ {
 			lbyte = strtonum("0x" substr($2, 16, 16))
-- 
1.9.2


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 02/12] cytune: remove from util-linux
  2014-05-11 19:26 [PATCH 01/12] tests: check /proc availability, and go-around if it is incomplete Sami Kerola
@ 2014-05-11 19:26 ` Sami Kerola
  2014-05-12 12:11   ` Karel Zak
  2014-05-11 19:26 ` [PATCH 03/12] blkid: remove unused variable Sami Kerola
                   ` (11 subsequent siblings)
  12 siblings, 1 reply; 21+ messages in thread
From: Sami Kerola @ 2014-05-11 19:26 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Assumption is there are not many who need this tool.  Whom ever they
might be the recommendation is to use the command from old util-linux
release.  Second reason to removal is difficulty to test hardware
specific command when none of the active project members does not seem to
have such.  Basically the command has reached dead end what comes to
maintainability of it.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 .gitignore                                         |   1 -
 bash-completion/Makemodule.am                      |   4 -
 bash-completion/cytune                             |  41 --
 configure.ac                                       |   9 -
 sys-utils/Makemodule.am                            |   7 -
 sys-utils/cyclades.h                               |  16 -
 sys-utils/cytune.8                                 | 194 ---------
 sys-utils/cytune.c                                 | 461 ---------------------
 tests/expected/build-sys/config-all                |   1 -
 tests/expected/build-sys/config-all-devel          |   1 -
 tests/expected/build-sys/config-all-non-nls        |   1 -
 tests/expected/build-sys/config-audit              |   1 -
 tests/expected/build-sys/config-chfnsh-libuser     |   1 -
 tests/expected/build-sys/config-chfnsh-no-password |   1 -
 tests/expected/build-sys/config-chfnsh-pam         |   1 -
 tests/expected/build-sys/config-core               |   1 -
 tests/expected/build-sys/config-devel              |   1 -
 tests/expected/build-sys/config-devel-new-mount    |   1 -
 tests/expected/build-sys/config-devel-non-docs     |   1 -
 tests/expected/build-sys/config-non-libblkid       |   1 -
 tests/expected/build-sys/config-non-libmount       |   1 -
 tests/expected/build-sys/config-non-libs           |   1 -
 tests/expected/build-sys/config-non-libuuid        |   1 -
 tests/expected/build-sys/config-non-nls            |   1 -
 tests/expected/build-sys/config-selinux            |   1 -
 tests/expected/build-sys/config-slang              |   1 -
 tests/expected/build-sys/config-static             |   1 -
 27 files changed, 752 deletions(-)
 delete mode 100644 bash-completion/cytune
 delete mode 100644 sys-utils/cyclades.h
 delete mode 100644 sys-utils/cytune.8
 delete mode 100644 sys-utils/cytune.c

diff --git a/.gitignore b/.gitignore
index bafe258..968a089 100644
--- a/.gitignore
+++ b/.gitignore
@@ -83,7 +83,6 @@ update.log
 /colrm
 /column
 /ctrlaltdel
-/cytune
 /delpart
 /dmesg
 /eject
diff --git a/bash-completion/Makemodule.am b/bash-completion/Makemodule.am
index aaf2737..0031aba 100644
--- a/bash-completion/Makemodule.am
+++ b/bash-completion/Makemodule.am
@@ -212,10 +212,6 @@ if BUILD_WDCTL
 dist_bashcompletion_DATA += \
 	bash-completion/wdctl
 endif
-if BUILD_CYTUNE
-dist_bashcompletion_DATA += \
-	bash-completion/cytune
-endif
 if LINUX
 dist_bashcompletion_DATA += \
 	bash-completion/blkdiscard \
diff --git a/bash-completion/cytune b/bash-completion/cytune
deleted file mode 100644
index f685c88..0000000
--- a/bash-completion/cytune
+++ /dev/null
@@ -1,41 +0,0 @@
-_cytune_module()
-{
-	local cur prev OPTS
-	COMPREPLY=()
-	cur="${COMP_WORDS[COMP_CWORD]}"
-	prev="${COMP_WORDS[COMP_CWORD-1]}"
-	case $prev in
-		'-s'|'--set-threshold'|'-S'|'--set-default-threshold'|'-t'|'--set-flush'|'-T'|'--set-default-flush')
-			COMPREPLY=( $(compgen -W "num" -- $cur) )
-			return 0
-			;;
-		'-i'|'--interval')
-			COMPREPLY=( $(compgen -W "seconds" -- $cur) )
-			return 0
-			;;
-		'-h'|'--help'|'-V'|'--version')
-			return 0
-			;;
-	esac
-	case $cur in
-		-*)
-			OPTS="--set-threshold
-				--get-threshold
-				--set-default-threshold
-				--set-flush
-				--get-glush
-				--set-default-flush
-				--stats
-				--interval
-				--help
-				--version"
-			COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
-			return 0
-			;;
-	esac
-	local IFS=$'\n'
-	compopt -o filenames
-	COMPREPLY=( $(compgen -f -- ${cur:-"/dev/tty"}) )
-	return 0
-}
-complete -F _cytune_module cytune
diff --git a/configure.ac b/configure.ac
index bb469bb..c5a3ef5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -847,15 +847,6 @@ UL_REQUIRES_LINUX([losetup])
 AM_CONDITIONAL([BUILD_LOSETUP], [test "x$build_losetup" = xyes])
 
 
-AC_ARG_ENABLE([cytune],
-  AS_HELP_STRING([--disable-cytune], [do not build cytune]),
-  [], [enable_cytune=check]
-)
-UL_BUILD_INIT([cytune])
-UL_REQUIRES_LINUX([cytune])
-AM_CONDITIONAL([BUILD_CYTUNE], [test "x$build_cytune" = xyes])
-
-
 AC_ARG_ENABLE([fsck],
   AS_HELP_STRING([--disable-fsck], [do not build fsck]),
   [], [enable_fsck=check]
diff --git a/sys-utils/Makemodule.am b/sys-utils/Makemodule.am
index eb78176..9d69bc6 100644
--- a/sys-utils/Makemodule.am
+++ b/sys-utils/Makemodule.am
@@ -40,13 +40,6 @@ dist_man_MANS += sys-utils/tunelp.8
 tunelp_SOURCES = sys-utils/tunelp.c sys-utils/lp.h
 endif
 
-if BUILD_CYTUNE
-usrbin_exec_PROGRAMS += cytune
-dist_man_MANS += sys-utils/cytune.8
-cytune_SOURCES = sys-utils/cytune.c sys-utils/cyclades.h
-cytune_LDADD = $(LDADD) libcommon.la
-endif
-
 if BUILD_FSTRIM
 sbin_PROGRAMS += fstrim
 dist_man_MANS += sys-utils/fstrim.8
diff --git a/sys-utils/cyclades.h b/sys-utils/cyclades.h
deleted file mode 100644
index afcf600..0000000
--- a/sys-utils/cyclades.h
+++ /dev/null
@@ -1,16 +0,0 @@
-struct cyclades_monitor {
-        unsigned long           int_count;
-        unsigned long           char_count;
-        unsigned long           char_max;
-        unsigned long           char_last;
-};
-
-#define CYGETMON                0x435901
-#define CYGETTHRESH             0x435902
-#define CYSETTHRESH             0x435903
-#define CYGETDEFTHRESH          0x435904
-#define CYSETDEFTHRESH          0x435905
-#define CYGETTIMEOUT            0x435906
-#define CYSETTIMEOUT            0x435907
-#define CYGETDEFTIMEOUT         0x435908
-#define CYSETDEFTIMEOUT         0x435909
diff --git a/sys-utils/cytune.8 b/sys-utils/cytune.8
deleted file mode 100644
index 3bf7afc..0000000
--- a/sys-utils/cytune.8
+++ /dev/null
@@ -1,194 +0,0 @@
-.\" cytune.8 --
-.\" Created: Sat Mar  4 17:44:53 1995 by faith@cs.unc.edu
-.\" Update: Sat Mar  4 18:22:24 1995 by faith@cs.unc.edu
-.\" Update: Sun Mar  5 06:40:12 1995 by njs@scifi.emi.net
-.\" Copyright 1995 Rickard E. Faith (faith@cs.unc.edu)
-.\"
-.\" Permission is granted to make and distribute verbatim copies of this
-.\" manual provided the copyright notice and this permission notice are
-.\" preserved on all copies.
-.\"
-.\" Permission is granted to copy and distribute modified versions of this
-.\" manual under the conditions for verbatim copying, provided that the
-.\" entire resulting derived work is distributed under the terms of a
-.\" permission notice identical to this one
-.\"
-.\" Since the Linux kernel and libraries are constantly changing, this
-.\" manual page may be incorrect or out-of-date.  The author(s) assume no
-.\" responsibility for errors or omissions, or for damages resulting from
-.\" the use of the information contained herein.  The author(s) may not
-.\" have taken the same level of care in the production of this manual,
-.\" which is licensed free of charge, as they might when working
-.\" professionally.
-.\"
-.\" Formatted or processed versions of this manual, if unaccompanied by
-.\" the source, must acknowledge the copyright and authors of this work.
-.\" "
-.TH CYTUNE 8 "September 2011" "util-linux" "System Administration"
-.SH NAME
-cytune \- tune driver parameters for Cyclades-Z multiport serial card
-.SH SYNOPSIS
-.B cytune
-.RI [options] tty ...
-.SH DESCRIPTION
-.B cytune
-queries and modifies the interruption threshold for the Cyclades driver.
-Each serial line on a Cyclades card has a 12-byte FIFO for input (and another
-12-byte FIFO for output).  The "threshold" specifies how many input
-characters must be present in the FIFO before an interruption is raised.
-When a Cyclades tty is opened, this threshold is set to a default value based
-on baud rate:
-.sp
-.RS
-Baud        Threshold
-.sp
-50-4800            10
-.br
-9600                8
-.br
-19200               4
-.br
-38400               2
-.br
-57600-150000        1
-.RE
-.PP
-If the threshold is set too low, the large number of interruptions can load
-the machine and decrease overall system throughput.  If the threshold is set
-too high, the FIFO buffer can overflow, and characters will be lost.  Slower
-machines, however, may not be able to deal with the interrupt load, and will
-require that the threshold be adjusted upwards.
-.PP
-If the cyclades driver was compiled with
-.B ENABLE_MONITORING
-defined, the cytune command can be used with the
-.B \-q
-option to report interrupts over the monitoring interval and characters
-transferred over the monitoring interval.  It will also report the state of
-the FIFO.  The maximum number of characters in the FIFO when an interrupt
-occurred, the instantaneous count of characters in the FIFO, and how many
-characters are now in the FIFO are reported.  This output might look like
-this:
-.sp
-.RS
-/dev/cubC0: 830 ints, 9130 chars; fifo: 11 threshold, 11 max, 11 now
-.br
-   166.259866 interrupts/second, 1828.858521 characters/second
-.RE
-.PP
-This output indicates that for this monitoring period, the interrupts were
-always being handled within one character time, because
-.B max
-never rose above
-.BR threshold .
-This is good, and you can probably run this way, provided that a large number
-of samples come out this way.  You will lose characters if you overrun the
-FIFO, as the Cyclades hardware does not seem to support the RTS RS-232 signal
-line for hardware flow control from the DCE to the DTE.
-.PP
-In query mode
-.B cytune
-will produce a summary report when ended with a SIGINT or when the threshold
-or timeout is changed.
-.PP
-There may be a responsiveness vs. throughput tradeoff.  The Cyclades card, at
-the higher speeds, is capable of putting a very high interrupt load on the
-system.  This will reduce the amount of CPU time available for other tasks on
-your system.  However, the time it takes to respond to a single character may
-be increased if you increase the threshold.  This might be noticed by
-monitoring
-.BR ping (8)
-times on a SLIP link controlled by a Cyclades card.  If your SLIP link is
-generally used for interactive work such as
-.BR telnet (1),
-you may want to leave the threshold low, so that characters are responded to
-as quickly as possible.  If your SLIP link is generally used for file
-transfer, WWW, and the like, setting the FIFO to a high value is likely to
-reduce the load on your system while not significantly affecting throughput.
-Alternatively, see the
-.B \-t
-or
-.B \-T
-options to adjust the time that the cyclades waits before flushing its
-buffer.  Units are 5ms.
-.PP
-If you are running a mouse on a Cyclades port, it is likely that you would
-want to maintain the threshold and timeout at a low value.
-.PP
-.SH OPTIONS
-.TP
-\fB\-s\fR, \fB\-\-set\-threshold\fR \fIvalue\fR
-Set the current threshold to
-.I value
-characters.  Note that if the
-.I tty
-is not being held open by another process, the threshold will be reset on the
-next open.  Only values between 1 and 12, inclusive, are permitted.
-.TP
-\fB\-t\fR, \fB\-\-set\-flush\fR \fIvalue\fR
-Set the current flush timeout to
-.I value
-units.  Note that if the
-.I tty
-is not being held open by another process, the threshold will be reset on the
-next open.  Only values between 0 and 255, inclusive, are permitted.  Setting
-.I value
-to zero forces the default, currently 0x20 (160ms), but soon to be 0x02
-(10ms).  Units are 5 ms.
-.TP
-\fB\-g\fR, \fB\-\-get-threshold\fR
-Get the current threshold and flush timeout values.
-.TP
-\fB\-S\fR, \fB\-\-set\-default\-threshold\fR \fIvalue\fR
-Set the default threshold to
-.I value
-characters.  When the
-.I tty
-is next opened, this value will be used instead of the default.  Only values
-between 1 and 12, inclusive, are permitted.
-.TP
-\fB\-T\fR, \fB\-\-set\-default\-flush\fR \fIvalue\fR
-Set the default flush timeout to
-.I value
-units.  When the
-.I tty
-is next opened, this value will be used instead of the default.  If
-.I value
-is zero, then the value will default to 0x20 (160ms), soon to be 0x02
-(10ms).
-.TP
-\fB\-G\fR, \fB\-\-get-flush\fR
-Get the default threshold and flush timeout values.
-.TP
-\fB\-q\fR, \fB\-\-stats\fR
-Gather statistics about the
-.IR tty .
-The results are only valid if the Cyclades driver has been compiled with
-.B ENABLE_MONITORING
-defined.  This is probably not the default.
-.TP
-\fB\-i\fR, \fB\-\-interval\fR \fIinterval\fR
-Statistics will be gathered every
-.I interval
-seconds.
-.SH BUGS
-If you run two copies of
-.B cytune
-at the same time to report statistics about the same port, the 'ints', 'chars',
-and 'max' value will be reset and not reported correctly.
-.B cytune
-should prevent this, but does not.
-.\" .SH AUTHOR
-.\" Nick Simicich (njs@scifi.emi.net), with modifications by
-.\" Rik Faith (faith@cs.unc.edu)
-.SH FILES
-.I /dev/ttyC[0-8]
-.br
-.I /dev/cubC[0-8]
-.SH "SEE ALSO"
-.BR setserial (8)
-.SH AVAILABILITY
-The cytune command is part of the util-linux package and is available from
-.UR ftp://\:ftp.kernel.org\:/pub\:/linux\:/utils\:/util-linux/
-Linux Kernel Archive
-.UE .
diff --git a/sys-utils/cytune.c b/sys-utils/cytune.c
deleted file mode 100644
index 15529ff..0000000
--- a/sys-utils/cytune.c
+++ /dev/null
@@ -1,461 +0,0 @@
-/* cytune.c -- Tune Cyclades driver
- *
- * Copyright 1995 Nick Simicich (njs@scifi.emi.net)
- * Modifications by Rik Faith (faith@cs.unc.edu)
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *      This product includes software developed by the Nick Simicich
- * 4. Neither the name of the Nick Simicich nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY NICK SIMICICH AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL NICK SIMICICH OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
- /*
-  * 1999-02-22 Arkadiusz Miśkiewicz <misiek@pld.ORG.PL>
-  * - added Native Language Support
-  * Sun Mar 21 1999 - Arnaldo Carvalho de Melo <acme@conectiva.com.br>
-  * - fixed strerr(errno) in gettext calls
-  */
-
-#include <getopt.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/ioctl.h>
-#include <unistd.h>
-#include <string.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <signal.h>
-#include <termios.h>
-
-#include "c.h"
-#include "cyclades.h"
-#include "closestream.h"
-#include "strutils.h"
-
-#if 0
-# ifndef XMIT
-#  include <linux/version.h>
-#  if LINUX_VERSION_CODE > 66056
-#   define XMIT
-#  endif
-# endif
-#endif
-
-#include "xalloc.h"
-#include "nls.h"
-/* Until it gets put in the kernel, toggle by hand. */
-#undef XMIT
-
-struct cyclades_control {
-	struct cyclades_monitor c;
-	int cfile;
-	int maxmax;
-	double maxtran;
-	double maxxmit;
-	unsigned long threshold_value;
-	unsigned long timeout_value;
-};
-struct cyclades_control *cmon;
-int cmon_index;
-
-static int global_argc, global_optind;
-static char ***global_argv;
-
-#define mvtime(tvpto, tvpfrom)  (((tvpto)->tv_sec = (tvpfrom)->tv_sec),(tvpto)->tv_usec = (tvpfrom)->tv_usec)
-
-static void __attribute__ ((__noreturn__)) usage(FILE * out)
-{
-	fprintf(out, USAGE_HEADER);
-	fprintf(out, _(" %s [options] <tty>...\n"), program_invocation_short_name);
-	fprintf(out, USAGE_OPTIONS);
-	fprintf(out, _(" -s, --set-threshold <num>          set interruption threshold value\n"));
-	fprintf(out, _(" -g, --get-threshold                display the current values\n"));
-	fprintf(out, _(" -S, --set-default-threshold <num>  set the default threshold value\n"));
-	fprintf(out, _(" -t, --set-flush <num>              set the flush timeout\n"));
-	fprintf(out, _(" -G, --get-flush                    display the default values\n"));
-	fprintf(out, _(" -T, --set-default-flush <num>      set the default flush timeout\n"));
-	fprintf(out, _(" -q, --stats                        display statistics about the tty\n"));
-	fprintf(out, _(" -i, --interval <seconds>           gather statistics every <seconds> interval\n"));
-	fprintf(out, USAGE_SEPARATOR);
-	fprintf(out, USAGE_HELP);
-	fprintf(out, USAGE_VERSION);
-	fprintf(out, USAGE_MAN_TAIL("cytune(8)"));
-
-	exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
-}
-
-static inline double dtime(struct timeval *tvpnew, struct timeval *tvpold)
-{
-	double diff;
-	diff = (double)tvpnew->tv_sec - (double)tvpold->tv_sec;
-	diff += ((double)tvpnew->tv_usec - (double)tvpold->tv_usec) / 1000000;
-	return diff;
-}
-
-static void summary(int sig)
-{
-	struct cyclades_control *cc;
-	int argc, local_optind;
-	char **argv;
-	int i;
-
-	argc = global_argc;
-	argv = *global_argv;
-	local_optind = global_optind;
-
-	if (sig > 0) {
-		for (i = local_optind; i < argc; i++) {
-			cc = &cmon[cmon_index];
-			warnx(_("File %s, For threshold value %lu, Maximum characters in fifo were %d,\n"
-				"and the maximum transfer rate in characters/second was %f"),
-			      argv[i], cc->threshold_value, cc->maxmax,
-			      cc->maxtran);
-		}
-		exit(EXIT_SUCCESS);
-	}
-	cc = &cmon[cmon_index];
-	if (cc->threshold_value > 0 && sig != -1) {
-		warnx(_("File %s, For threshold value %lu and timeout value %lu, Maximum characters in fifo were %d,\n"
-			"and the maximum transfer rate in characters/second was %f"),
-		      argv[cmon_index + local_optind], cc->threshold_value,
-		      cc->timeout_value, cc->maxmax, cc->maxtran);
-	}
-	cc->maxmax = 0;
-	cc->maxtran = 0.0;
-	cc->threshold_value = 0;
-	cc->timeout_value = 0;
-}
-
-static void query_tty_stats(int argc, char **argv, int interval, int numfiles,
-		     unsigned long *threshold_value,
-		     unsigned long *timeout_value)
-{
-	struct cyclades_monitor cywork;
-	struct timeval lasttime, thistime;
-	struct timezone tz = { 0, 0 };
-	int i;
-	double diff;
-	double xfer_rate;
-#ifdef XMIT
-	double xmit_rate;
-#endif
-
-	cmon = xmalloc(sizeof(struct cyclades_control) * numfiles);
-
-	if (signal(SIGINT, summary) ||
-	    signal(SIGQUIT, summary) || signal(SIGTERM, summary))
-		err(EXIT_FAILURE, _("cannot set signal handler"));
-	if (gettimeofday(&lasttime, &tz))
-		err(EXIT_FAILURE, _("gettimeofday failed"));
-
-	for (i = optind; i < argc; i++) {
-		cmon_index = i - optind;
-		cmon[cmon_index].cfile = open(argv[i], O_RDONLY);
-		if (cmon[cmon_index].cfile == -1)
-			err(EXIT_FAILURE, _("cannot open %s"), argv[i]);
-		if (ioctl
-		    (cmon[cmon_index].cfile, CYGETMON, &cmon[cmon_index].c))
-			err(EXIT_FAILURE, _("cannot issue CYGETMON on %s"),
-			    argv[i]);
-		summary(-1);
-		if (ioctl
-		    (cmon[cmon_index].cfile, CYGETTHRESH, &threshold_value))
-			err(EXIT_FAILURE, _("cannot get threshold for %s"),
-			    argv[i]);
-		if (ioctl(cmon[cmon_index].cfile, CYGETTIMEOUT, &timeout_value))
-			err(EXIT_FAILURE, _("cannot get timeout for %s"),
-			    argv[i]);
-	}
-	while (1) {
-		sleep(interval);
-
-		if (gettimeofday(&thistime, &tz))
-			err(EXIT_FAILURE, _("gettimeofday failed"));
-		diff = dtime(&thistime, &lasttime);
-		mvtime(&lasttime, &thistime);
-
-		for (i = optind; i < argc; i++) {
-			cmon_index = i - optind;
-			if (ioctl(cmon[cmon_index].cfile, CYGETMON, &cywork))
-				err(EXIT_FAILURE,
-				    _("cannot issue CYGETMON on %s"), argv[i]);
-			if (ioctl
-			    (cmon[cmon_index].cfile, CYGETTHRESH,
-			     &threshold_value))
-				err(EXIT_FAILURE,
-				    _("cannot get threshold for %s"), argv[i]);
-			if (ioctl
-			    (cmon[cmon_index].cfile, CYGETTIMEOUT,
-			     &timeout_value))
-				err(EXIT_FAILURE,
-				    _("cannot get timeout for %s"), argv[i]);
-
-			xfer_rate = cywork.char_count / diff;
-#ifdef XMIT
-			xmit_rate = cywork.send_count / diff;
-#endif
-			if ((*threshold_value) !=
-			    cmon[cmon_index].threshold_value
-			    || (*timeout_value) !=
-			    cmon[cmon_index].timeout_value) {
-				summary(-2);
-				/* Note that the summary must come before the
-				 * setting of threshold_value */
-				cmon[cmon_index].threshold_value =
-				    (*threshold_value);
-				cmon[cmon_index].timeout_value =
-				    (*timeout_value);
-			} else {
-				/* Don't record this first cycle after change */
-				if (xfer_rate > cmon[cmon_index].maxtran)
-					cmon[cmon_index].maxtran = xfer_rate;
-#ifdef XMIT
-				if (xmit_rate > cmon[cmon_index].maxxmit)
-					cmon[cmon_index].maxxmit = xmit_rate;
-#endif
-				if (cmon[cmon_index].maxmax < 0 ||
-				    cywork.char_max >
-				    (unsigned long)cmon[cmon_index].maxmax)
-					cmon[cmon_index].maxmax =
-					    cywork.char_max;
-			}
-
-#ifdef XMIT
-			printf(_("%s: %lu ints, %lu/%lu chars; fifo: %lu thresh, %lu tmout, "
-				 "%lu max, %lu now\n"), argv[i],
-			       cywork.int_count, cywork.char_count,
-			       cywork.send_count, *threshold_value,
-			       *timeout_value, cywork.char_max,
-			       cywork.char_last);
-			printf(_("   %f int/sec; %f rec, %f send (char/sec)\n"),
-			       cywork.int_count / diff, xfer_rate, xmit_rate);
-#else
-			printf(_("%s: %lu ints, %lu chars; fifo: %lu thresh, %lu tmout, "
-				 "%lu max, %lu now\n"), argv[i],
-			       cywork.int_count, cywork.char_count,
-			       *threshold_value, *timeout_value, cywork.char_max,
-			       cywork.char_last);
-			printf(_("   %f int/sec; %f rec (char/sec)\n"),
-			       cywork.int_count / diff, xfer_rate);
-#endif
-			memcpy(&cmon[cmon_index].c, &cywork,
-			       sizeof(struct cyclades_monitor));
-		}
-	}
-
-	free(cmon);
-	return;
-}
-
-int main(int argc, char **argv)
-{
-	int query = 0;
-	int interval = 1;
-	int set = 0;
-	int set_val = -1;
-	int get = 0;
-	int set_def = 0;
-	int set_def_val = -1;
-	int get_def = 0;
-	int set_time = 0;
-	int set_time_val = -1;
-	int set_def_time = 0;
-	int set_def_time_val = -1;
-	int errflg = 0;
-	int file;
-	int numfiles;
-	int i;
-	unsigned long threshold_value;
-	unsigned long timeout_value;
-
-	static const struct option longopts[] = {
-		{"set-threshold", required_argument, NULL, 's'},
-		{"get-threshold", no_argument, NULL, 'g'},
-		{"set-default-threshold", required_argument, NULL, 'S'},
-		{"set-flush", required_argument, NULL, 't'},
-		{"get-flush", no_argument, NULL, 'G'},
-		{"set-default-flush", required_argument, NULL, 'T'},
-		{"stats", no_argument, NULL, 'q'},
-		{"interval", required_argument, NULL, 'i'},
-		{"version", no_argument, NULL, 'V'},
-		{"help", no_argument, NULL, 'h'},
-		{NULL, 0, NULL, 0}
-	};
-
-	/* For signal routine. */
-	global_argc = argc;
-	global_argv = &argv;
-
-	setlocale(LC_ALL, "");
-	bindtextdomain(PACKAGE, LOCALEDIR);
-	textdomain(PACKAGE);
-	atexit(close_stdout);
-
-	while ((i =
-		getopt_long(argc, argv, "qs:S:t:T:gGi:Vh", longopts,
-			    NULL)) != -1) {
-		switch (i) {
-		case 'q':
-			query = 1;
-			break;
-		case 'i':
-			interval = strtou32_or_err(optarg,
-						_("Invalid interval value"));
-			if (interval < 1) {
-				warnx(_("Invalid interval value: %d"),
-				      interval);
-				errflg++;
-			}
-			break;
-		case 's':
-			++set;
-			set_val = strtou32_or_err(optarg, _("Invalid set value"));
-			if (set_val < 1 || 12 < set_val) {
-				warnx(_("Invalid set value: %d"), set_val);
-				errflg++;
-			}
-			break;
-		case 'S':
-			++set_def;
-			set_def_val = strtou32_or_err(optarg,
-						_("Invalid default value"));
-			if (set_def_val < 0 || 12 < set_def_val) {
-				warnx(_("Invalid default value: %d"),
-				      set_def_val);
-				errflg++;
-			}
-			break;
-		case 't':
-			++set_time;
-			set_time_val = strtou32_or_err(optarg,
-						_("Invalid set time value"));
-			if (set_time_val < 1 || 255 < set_time_val) {
-				warnx(_("Invalid set time value: %d"),
-				      set_time_val);
-				errflg++;
-			}
-			break;
-		case 'T':
-			++set_def_time;
-			set_def_time_val = strtou32_or_err(optarg,
-						_("Invalid default time value"));
-			if (set_def_time_val < 0 || 255 < set_def_time_val) {
-				warnx(_("Invalid default time value: %d"),
-				      set_def_time_val);
-				errflg++;
-			}
-			break;
-		case 'g':
-			++get;
-			break;
-		case 'G':
-			++get_def;
-			break;
-		case 'V':
-			printf(_("%s from %s\n"), program_invocation_short_name,
-			       PACKAGE_STRING);
-			return EXIT_SUCCESS;
-		case 'h':
-			usage(stdout);
-		default:
-			usage(stderr);
-		}
-	}
-	numfiles = argc - optind;
-
-	if (errflg
-	    || (numfiles == 0)
-	    || (!query && !set && !set_def && !get && !get_def && !set_time && !set_def_time)
-	    || (set && set_def)
-	    || (set_time && set_def_time)
-	    || (get && get_def))
-		usage(stderr);
-
-	/* For signal routine. */
-	global_optind = optind;
-
-	if (set || set_def) {
-		for (i = optind; i < argc; i++) {
-			file = open(argv[i], O_RDONLY);
-			if (file == -1)
-				err(EXIT_FAILURE, _("cannot open %s"), argv[i]);
-			if (ioctl(file,
-				  set ? CYSETTHRESH : CYSETDEFTHRESH,
-				  set ? set_val : set_def_val))
-				err(EXIT_FAILURE,
-				    _("cannot set %s to threshold %d"), argv[i],
-				    set ? set_val : set_def_val);
-			close(file);
-		}
-	}
-	if (set_time || set_def_time) {
-		for (i = optind; i < argc; i++) {
-			file = open(argv[i], O_RDONLY);
-			if (file == -1)
-				err(EXIT_FAILURE, _("cannot open %s"), argv[i]);
-			if (ioctl(file,
-				  set_time ? CYSETTIMEOUT : CYSETDEFTIMEOUT,
-				  set_time ? set_time_val : set_def_time_val))
-				err(EXIT_FAILURE,
-				    _("cannot set %s to time threshold %d"),
-				    argv[i],
-				    set_time ? set_time_val : set_def_time_val);
-			close(file);
-		}
-	}
-
-	if (get || get_def) {
-		for (i = optind; i < argc; i++) {
-			file = open(argv[i], O_RDONLY);
-			if (file == -1)
-				err(EXIT_FAILURE, _("cannot open %s"), argv[i]);
-			if (ioctl
-			    (file, get ? CYGETTHRESH : CYGETDEFTHRESH,
-			     &threshold_value))
-				err(EXIT_FAILURE,
-				    _("cannot get threshold for %s"), argv[i]);
-			if (ioctl
-			    (file, get ? CYGETTIMEOUT : CYGETDEFTIMEOUT,
-			     &timeout_value))
-				err(EXIT_FAILURE,
-				    _("cannot get timeout for %s"), argv[i]);
-			close(file);
-			if (get)
-				printf(_("%s: %ld current threshold and %ld current timeout\n"),
-					argv[i], threshold_value, timeout_value);
-			else
-				printf(_("%s: %ld default threshold and %ld default timeout\n"),
-					argv[i], threshold_value, timeout_value);
-		}
-	}
-
-	if (!query)
-		return EXIT_SUCCESS;
-
-	query_tty_stats(argc, argv, interval, numfiles, &threshold_value, &timeout_value);
-
-	return EXIT_SUCCESS;
-}
diff --git a/tests/expected/build-sys/config-all b/tests/expected/build-sys/config-all
index 2b2a487..428490f 100644
--- a/tests/expected/build-sys/config-all
+++ b/tests/expected/build-sys/config-all
@@ -37,7 +37,6 @@ colcrt:
 colrm:  
 column:  
 ctrlaltdel:  
-cytune:  
 delpart:  
 dmesg:  librt 
 fallocate:  
diff --git a/tests/expected/build-sys/config-all-devel b/tests/expected/build-sys/config-all-devel
index f3933aa..812777d 100644
--- a/tests/expected/build-sys/config-all-devel
+++ b/tests/expected/build-sys/config-all-devel
@@ -73,7 +73,6 @@ mountpoint:  libblkid libmount libselinux libsepol libuuid
 arch:  
 chcpu:  
 ctrlaltdel:  
-cytune:  
 dmesg:  
 fallocate:  
 flock:  
diff --git a/tests/expected/build-sys/config-all-non-nls b/tests/expected/build-sys/config-all-non-nls
index 2b2a487..428490f 100644
--- a/tests/expected/build-sys/config-all-non-nls
+++ b/tests/expected/build-sys/config-all-non-nls
@@ -37,7 +37,6 @@ colcrt:
 colrm:  
 column:  
 ctrlaltdel:  
-cytune:  
 delpart:  
 dmesg:  librt 
 fallocate:  
diff --git a/tests/expected/build-sys/config-audit b/tests/expected/build-sys/config-audit
index 4f37b1c..cb623be 100644
--- a/tests/expected/build-sys/config-audit
+++ b/tests/expected/build-sys/config-audit
@@ -34,7 +34,6 @@ colcrt:
 colrm:  
 column:  
 ctrlaltdel:  
-cytune:  
 delpart:  
 dmesg:  librt 
 fallocate:  
diff --git a/tests/expected/build-sys/config-chfnsh-libuser b/tests/expected/build-sys/config-chfnsh-libuser
index 4863257..6ac5e56 100644
--- a/tests/expected/build-sys/config-chfnsh-libuser
+++ b/tests/expected/build-sys/config-chfnsh-libuser
@@ -36,7 +36,6 @@ colcrt:
 colrm:  
 column:  
 ctrlaltdel:  
-cytune:  
 delpart:  
 dmesg:  librt 
 fallocate:  
diff --git a/tests/expected/build-sys/config-chfnsh-no-password b/tests/expected/build-sys/config-chfnsh-no-password
index 09831b6..7d04805 100644
--- a/tests/expected/build-sys/config-chfnsh-no-password
+++ b/tests/expected/build-sys/config-chfnsh-no-password
@@ -36,7 +36,6 @@ colcrt:
 colrm:  
 column:  
 ctrlaltdel:  
-cytune:  
 delpart:  
 dmesg:  librt 
 fallocate:  
diff --git a/tests/expected/build-sys/config-chfnsh-pam b/tests/expected/build-sys/config-chfnsh-pam
index ccf0728..5fa2be1 100644
--- a/tests/expected/build-sys/config-chfnsh-pam
+++ b/tests/expected/build-sys/config-chfnsh-pam
@@ -36,7 +36,6 @@ colcrt:
 colrm:  
 column:  
 ctrlaltdel:  
-cytune:  
 delpart:  
 dmesg:  librt 
 fallocate:  
diff --git a/tests/expected/build-sys/config-core b/tests/expected/build-sys/config-core
index 1d14682..a0e6dd4 100644
--- a/tests/expected/build-sys/config-core
+++ b/tests/expected/build-sys/config-core
@@ -34,7 +34,6 @@ colcrt:
 colrm:  
 column:  
 ctrlaltdel:  
-cytune:  
 delpart:  
 dmesg:  librt 
 fallocate:  
diff --git a/tests/expected/build-sys/config-devel b/tests/expected/build-sys/config-devel
index ef6c556..1d377d9 100644
--- a/tests/expected/build-sys/config-devel
+++ b/tests/expected/build-sys/config-devel
@@ -37,7 +37,6 @@ colcrt:
 colrm:  
 column:  
 ctrlaltdel:  
-cytune:  
 delpart:  
 dmesg:  librt 
 fallocate:  
diff --git a/tests/expected/build-sys/config-devel-new-mount b/tests/expected/build-sys/config-devel-new-mount
index 121a3f6..d56be6c 100644
--- a/tests/expected/build-sys/config-devel-new-mount
+++ b/tests/expected/build-sys/config-devel-new-mount
@@ -75,7 +75,6 @@ umount:  libblkid libmount libselinux libsepol libuuid
 arch:  
 chcpu:  
 ctrlaltdel:  
-cytune:  
 dmesg:  
 fallocate:  
 flock:  
diff --git a/tests/expected/build-sys/config-devel-non-docs b/tests/expected/build-sys/config-devel-non-docs
index ef6c556..1d377d9 100644
--- a/tests/expected/build-sys/config-devel-non-docs
+++ b/tests/expected/build-sys/config-devel-non-docs
@@ -37,7 +37,6 @@ colcrt:
 colrm:  
 column:  
 ctrlaltdel:  
-cytune:  
 delpart:  
 dmesg:  librt 
 fallocate:  
diff --git a/tests/expected/build-sys/config-non-libblkid b/tests/expected/build-sys/config-non-libblkid
index c284f08..fa9ce33 100644
--- a/tests/expected/build-sys/config-non-libblkid
+++ b/tests/expected/build-sys/config-non-libblkid
@@ -15,7 +15,6 @@ colcrt:
 colrm:  
 column:  
 ctrlaltdel:  
-cytune:  
 dmesg:  librt 
 fallocate:  
 fdformat:  
diff --git a/tests/expected/build-sys/config-non-libmount b/tests/expected/build-sys/config-non-libmount
index 22e1f96..78e659f 100644
--- a/tests/expected/build-sys/config-non-libmount
+++ b/tests/expected/build-sys/config-non-libmount
@@ -22,7 +22,6 @@ colcrt:
 colrm:  
 column:  
 ctrlaltdel:  
-cytune:  
 delpart:  
 dmesg:  librt 
 fallocate:  
diff --git a/tests/expected/build-sys/config-non-libs b/tests/expected/build-sys/config-non-libs
index 46cc7be..2aa4820 100644
--- a/tests/expected/build-sys/config-non-libs
+++ b/tests/expected/build-sys/config-non-libs
@@ -10,7 +10,6 @@ colcrt:
 colrm:  
 column:  
 ctrlaltdel:  
-cytune:  
 dmesg:  librt 
 fallocate:  
 fdformat:  
diff --git a/tests/expected/build-sys/config-non-libuuid b/tests/expected/build-sys/config-non-libuuid
index 6279aa5..91fe340 100644
--- a/tests/expected/build-sys/config-non-libuuid
+++ b/tests/expected/build-sys/config-non-libuuid
@@ -30,7 +30,6 @@ colcrt:
 colrm:  
 column:  
 ctrlaltdel:  
-cytune:  
 delpart:  
 dmesg:  librt 
 fallocate:  
diff --git a/tests/expected/build-sys/config-non-nls b/tests/expected/build-sys/config-non-nls
index 1d14682..a0e6dd4 100644
--- a/tests/expected/build-sys/config-non-nls
+++ b/tests/expected/build-sys/config-non-nls
@@ -34,7 +34,6 @@ colcrt:
 colrm:  
 column:  
 ctrlaltdel:  
-cytune:  
 delpart:  
 dmesg:  librt 
 fallocate:  
diff --git a/tests/expected/build-sys/config-selinux b/tests/expected/build-sys/config-selinux
index c0faa85..c2644ab 100644
--- a/tests/expected/build-sys/config-selinux
+++ b/tests/expected/build-sys/config-selinux
@@ -34,7 +34,6 @@ colcrt:
 colrm:  
 column:  
 ctrlaltdel:  
-cytune:  
 delpart:  
 dmesg:  librt 
 fallocate:  
diff --git a/tests/expected/build-sys/config-slang b/tests/expected/build-sys/config-slang
index 7baebb9..3636492 100644
--- a/tests/expected/build-sys/config-slang
+++ b/tests/expected/build-sys/config-slang
@@ -34,7 +34,6 @@ colcrt:
 colrm:  
 column:  
 ctrlaltdel:  
-cytune:  
 delpart:  
 dmesg:  librt 
 fallocate:  
diff --git a/tests/expected/build-sys/config-static b/tests/expected/build-sys/config-static
index 5b91300..ba2184a 100644
--- a/tests/expected/build-sys/config-static
+++ b/tests/expected/build-sys/config-static
@@ -35,7 +35,6 @@ colcrt:
 colrm:  
 column:  
 ctrlaltdel:  
-cytune:  
 delpart:  
 dmesg:  librt 
 fallocate:  
-- 
1.9.2


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 03/12] blkid: remove unused variable
  2014-05-11 19:26 [PATCH 01/12] tests: check /proc availability, and go-around if it is incomplete Sami Kerola
  2014-05-11 19:26 ` [PATCH 02/12] cytune: remove from util-linux Sami Kerola
@ 2014-05-11 19:26 ` Sami Kerola
  2014-05-11 19:26 ` [PATCH 04/12] logger: fail when io vector number exceeds maximum Sami Kerola
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 21+ messages in thread
From: Sami Kerola @ 2014-05-11 19:26 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 misc-utils/blkid.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/misc-utils/blkid.c b/misc-utils/blkid.c
index b3eade5..0d0ea6a 100644
--- a/misc-utils/blkid.c
+++ b/misc-utils/blkid.c
@@ -366,7 +366,7 @@ static void print_tags(blkid_dev dev, char *show[], int output)
 
 static int append_str(char **res, size_t *sz, const char *a, const char *b)
 {
-	char *str = *res;
+	char *str;
 	size_t asz = a ? strlen(a) : 0;
 	size_t bsz = b ? strlen(b) : 0;
 	size_t len = *sz + asz + bsz;
@@ -374,7 +374,7 @@ static int append_str(char **res, size_t *sz, const char *a, const char *b)
 	if (!len)
 		return -1;
 
-	*res = str = xrealloc(str, len + 1);
+	str = xrealloc(str, len + 1);
 	str += *sz;
 
 	if (a) {
-- 
1.9.2


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 04/12] logger: fail when io vector number exceeds maximum
  2014-05-11 19:26 [PATCH 01/12] tests: check /proc availability, and go-around if it is incomplete Sami Kerola
  2014-05-11 19:26 ` [PATCH 02/12] cytune: remove from util-linux Sami Kerola
  2014-05-11 19:26 ` [PATCH 03/12] blkid: remove unused variable Sami Kerola
@ 2014-05-11 19:26 ` Sami Kerola
  2014-05-11 19:26 ` [PATCH 05/12] logger: check numeric priority and facility input values Sami Kerola
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 21+ messages in thread
From: Sami Kerola @ 2014-05-11 19:26 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Earlier version silently failed without logging anything.

$ logger --journald=/etc/services ; echo $?
1

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 misc-utils/logger.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/misc-utils/logger.c b/misc-utils/logger.c
index f3bdc90..fccba38 100644
--- a/misc-utils/logger.c
+++ b/misc-utils/logger.c
@@ -37,6 +37,7 @@
  */
 
 #include <errno.h>
+#include <limits.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <time.h>
@@ -231,6 +232,8 @@ static int journald_entry(FILE *fp)
 		}
 		if (lines == vectors) {
 			vectors *= 2;
+			if (IOV_MAX < vectors)
+				errx(EXIT_FAILURE, _("maximum input lines (%d) exceeded"), IOV_MAX);
 			iovec = xrealloc(iovec, vectors * sizeof(struct iovec));
 		}
 		iovec[lines].iov_base = buf;
@@ -415,7 +418,9 @@ int main(int argc, char **argv)
 		int ret = journald_entry(jfd);
 		if (stdin != jfd)
 			fclose(jfd);
-		return ret ? EXIT_FAILURE : EXIT_SUCCESS;
+		if (ret)
+			errx(EXIT_FAILURE, "journald entry could not be wrote");
+		return EXIT_SUCCESS;
 	}
 #endif
 	if (server)
-- 
1.9.2


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 05/12] logger: check numeric priority and facility input values
  2014-05-11 19:26 [PATCH 01/12] tests: check /proc availability, and go-around if it is incomplete Sami Kerola
                   ` (2 preceding siblings ...)
  2014-05-11 19:26 ` [PATCH 04/12] logger: fail when io vector number exceeds maximum Sami Kerola
@ 2014-05-11 19:26 ` Sami Kerola
  2014-05-11 19:26 ` [PATCH 06/12] build-sys: remove unnecessary void casts Sami Kerola
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 21+ messages in thread
From: Sami Kerola @ 2014-05-11 19:26 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Earlier use of unknown facility or priority number was accepted, and
resulted in unexpected result.  For example when looking journalctl
--priority=7.8 was converted to priotity 0 and facility 1.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 misc-utils/logger.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/misc-utils/logger.c b/misc-utils/logger.c
index fccba38..b7f9064 100644
--- a/misc-utils/logger.c
+++ b/misc-utils/logger.c
@@ -99,9 +99,20 @@ static int decode(char *name, CODE *codetab)
 {
 	register CODE *c;
 
-	if (isdigit(*name))
-		return (atoi(name));
-
+	if (name == NULL || *name == '\0')
+		return -1;
+	if (isdigit(*name)) {
+		int num;
+		char *end = NULL;
+
+		num = strtol(name, &end, 10);
+		if (errno || name == end || (end && *end))
+			return -1;
+		for (c = codetab; c->c_name; c++)
+			if (num == c->c_val)
+				return num;
+		return -1;
+	}
 	for (c = codetab; c->c_name; c++)
 		if (!strcasecmp(name, c->c_name))
 			return (c->c_val);
-- 
1.9.2


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 06/12] build-sys: remove unnecessary void casts
  2014-05-11 19:26 [PATCH 01/12] tests: check /proc availability, and go-around if it is incomplete Sami Kerola
                   ` (3 preceding siblings ...)
  2014-05-11 19:26 ` [PATCH 05/12] logger: check numeric priority and facility input values Sami Kerola
@ 2014-05-11 19:26 ` Sami Kerola
  2014-05-11 19:26 ` [PATCH 07/12] term-utils: avoid error message string length couting errors Sami Kerola
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 21+ messages in thread
From: Sami Kerola @ 2014-05-11 19:26 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 misc-utils/logger.c |  2 +-
 term-utils/ttymsg.c | 26 +++++++++++++-------------
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/misc-utils/logger.c b/misc-utils/logger.c
index b7f9064..a862e55 100644
--- a/misc-utils/logger.c
+++ b/misc-utils/logger.c
@@ -275,7 +275,7 @@ static void mysyslog(int fd, int logflags, int pri, char *tag, char *msg)
 		       if (!cp)
 			       cp = "<someone>";
 	       }
-               (void)time(&now);
+	       time(&now);
 	       tp = ctime(&now)+4;
 
                snprintf(buf, sizeof(buf), "<%d>%.15s %.200s%s: %.400s",
diff --git a/term-utils/ttymsg.c b/term-utils/ttymsg.c
index 8bf993c..fb2614f 100644
--- a/term-utils/ttymsg.c
+++ b/term-utils/ttymsg.c
@@ -85,10 +85,10 @@ ttymsg(struct iovec *iov, size_t iovcnt, char *line, int tmout) {
 	   also wrong since people use /dev/pts/xxx. */
 
 	if (strlen(line) + sizeof(_PATH_DEV) + 1 > sizeof(device)) {
-		(void) sprintf(errbuf, _("excessively long line arg"));
+		sprintf(errbuf, _("excessively long line arg"));
 		return (errbuf);
 	}
-	(void) sprintf(device, "%s%s", _PATH_DEV, line);
+	sprintf(device, "%s%s", _PATH_DEV, line);
 
 	/*
 	 * open will fail on slip lines or exclusive-use lines
@@ -99,7 +99,7 @@ ttymsg(struct iovec *iov, size_t iovcnt, char *line, int tmout) {
 			return (NULL);
 		if (strlen(strerror(errno)) > 1000)
 			return (NULL);
-		(void) sprintf(errbuf, "%s: %m", device);
+		sprintf(errbuf, "%s: %m", device);
 		errbuf[1024] = 0;
 		return (errbuf);
 	}
@@ -134,32 +134,32 @@ ttymsg(struct iovec *iov, size_t iovcnt, char *line, int tmout) {
 			sigset_t sigmask;
 
 			if (forked) {
-				(void) close(fd);
+				close(fd);
 				_exit(EXIT_FAILURE);
 			}
 			cpid = fork();
 			if (cpid < 0) {
 				if (strlen(strerror(errno)) > 1000)
-					(void) sprintf(errbuf, _("cannot fork"));
+					sprintf(errbuf, _("cannot fork"));
 				else {
 					errsv = errno;
-					(void) sprintf(errbuf,
+					sprintf(errbuf,
 						 _("fork: %s"), strerror(errsv));
 				}
-				(void) close(fd);
+				close(fd);
 				return (errbuf);
 			}
 			if (cpid) {	/* parent */
-				(void) close(fd);
+				close(fd);
 				return (NULL);
 			}
 			forked++;
 			/* wait at most tmout seconds */
-			(void) signal(SIGALRM, SIG_DFL);
-			(void) signal(SIGTERM, SIG_DFL); /* XXX */
+			signal(SIGALRM, SIG_DFL);
+			signal(SIGTERM, SIG_DFL); /* XXX */
 			sigemptyset(&sigmask);
 			sigprocmask (SIG_SETMASK, &sigmask, NULL);
-			(void) alarm((u_int)tmout);
+			alarm((u_int)tmout);
 			flags = fcntl(fd, F_GETFL);
 			fcntl(flags, F_SETFL, (long) (flags & ~O_NONBLOCK));
 			continue;
@@ -175,11 +175,11 @@ ttymsg(struct iovec *iov, size_t iovcnt, char *line, int tmout) {
 		if (forked)
 			_exit(EXIT_FAILURE);
 		if (strlen(strerror(errno)) > 1000)
-			(void) sprintf(errbuf, _("%s: BAD ERROR, message is "
+			sprintf(errbuf, _("%s: BAD ERROR, message is "
 						 "far too long"), device);
 		else {
 			errsv = errno;
-			(void) sprintf(errbuf, "%s: %s", device,
+			sprintf(errbuf, "%s: %s", device,
 				       strerror(errsv));
 		}
 		errbuf[1024] = 0;
-- 
1.9.2


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 07/12] term-utils: avoid error message string length couting errors
  2014-05-11 19:26 [PATCH 01/12] tests: check /proc availability, and go-around if it is incomplete Sami Kerola
                   ` (4 preceding siblings ...)
  2014-05-11 19:26 ` [PATCH 06/12] build-sys: remove unnecessary void casts Sami Kerola
@ 2014-05-11 19:26 ` Sami Kerola
  2014-05-12 12:05   ` Karel Zak
  2014-05-11 19:26 ` [PATCH 08/12] wall: replace magic number by named value Sami Kerola
                   ` (6 subsequent siblings)
  12 siblings, 1 reply; 21+ messages in thread
From: Sami Kerola @ 2014-05-11 19:26 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Remove various magic numbers with either a string lenght count, or a
symbolic variable that is recognized by gdb.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 term-utils/ttymsg.c | 57 ++++++++++++++++++++++++++---------------------------
 1 file changed, 28 insertions(+), 29 deletions(-)

diff --git a/term-utils/ttymsg.c b/term-utils/ttymsg.c
index fb2614f..3a2565d 100644
--- a/term-utils/ttymsg.c
+++ b/term-utils/ttymsg.c
@@ -58,6 +58,8 @@
 #include "pathnames.h"
 #include "ttymsg.h"
 
+enum { ERR_BUFLEN = MAXNAMLEN + 1024 };
+
 /*
  * Display the contents of a uio structure on a terminal.  Used by wall(1),
  * syslogd(8), and talkd(8).  Forks and finishes in child if write would block,
@@ -68,14 +70,16 @@
 char *
 ttymsg(struct iovec *iov, size_t iovcnt, char *line, int tmout) {
 	static char device[MAXNAMLEN];
-	static char errbuf[MAXNAMLEN+1024];
+	static char errbuf[ERR_BUFLEN];
 	size_t cnt, left;
 	ssize_t wret;
 	struct iovec localiov[6];
-	int fd, forked = 0, errsv;
+	int fd, forked = 0;
 
-	if (iovcnt > sizeof(localiov) / sizeof(localiov[0]))
-		return (_("internal error: too many iov's"));
+	if (iovcnt > sizeof(localiov) / sizeof(localiov[0])) {
+		sprintf(errbuf, _("internal error: too many iov's"));
+		return errbuf;
+	}
 
 	/* The old code here rejected the line argument when it contained a '/',
 	   saying: "A slash may be an attempt to break security...".
@@ -86,7 +90,7 @@ ttymsg(struct iovec *iov, size_t iovcnt, char *line, int tmout) {
 
 	if (strlen(line) + sizeof(_PATH_DEV) + 1 > sizeof(device)) {
 		sprintf(errbuf, _("excessively long line arg"));
-		return (errbuf);
+		return errbuf;
 	}
 	sprintf(device, "%s%s", _PATH_DEV, line);
 
@@ -96,12 +100,13 @@ ttymsg(struct iovec *iov, size_t iovcnt, char *line, int tmout) {
 	 */
 	if ((fd = open(device, O_WRONLY|O_NONBLOCK, 0)) < 0) {
 		if (errno == EBUSY || errno == EACCES)
-			return (NULL);
-		if (strlen(strerror(errno)) > 1000)
-			return (NULL);
-		sprintf(errbuf, "%s: %m", device);
-		errbuf[1024] = 0;
-		return (errbuf);
+			return NULL;
+		if (strlen(device) + 2 + strlen(strerror(errno)) + 1 < ERR_BUFLEN)
+			sprintf(errbuf, "%s: %s", device, strerror(errno));
+		else
+			sprintf(errbuf, _("device open error message exceeded maximum length"));
+		errbuf[ERR_BUFLEN] = 0;
+		return errbuf;
 	}
 
 	for (cnt = left = 0; cnt < iovcnt; ++cnt)
@@ -139,19 +144,16 @@ ttymsg(struct iovec *iov, size_t iovcnt, char *line, int tmout) {
 			}
 			cpid = fork();
 			if (cpid < 0) {
-				if (strlen(strerror(errno)) > 1000)
-					sprintf(errbuf, _("cannot fork"));
-				else {
-					errsv = errno;
-					sprintf(errbuf,
-						 _("fork: %s"), strerror(errsv));
-				}
+				if (6 + strlen(strerror(errno)) + 1 < ERR_BUFLEN)
+					sprintf(errbuf, _("fork: %s"), strerror(errno));
+				else
+					sprintf(errbuf, _("cannot fork and error message length exceeded"));
 				close(fd);
-				return (errbuf);
+				return errbuf;
 			}
 			if (cpid) {	/* parent */
 				close(fd);
-				return (NULL);
+				return NULL;
 			}
 			forked++;
 			/* wait at most tmout seconds */
@@ -174,19 +176,16 @@ ttymsg(struct iovec *iov, size_t iovcnt, char *line, int tmout) {
 			warn(_("write failed: %s"), device);
 		if (forked)
 			_exit(EXIT_FAILURE);
-		if (strlen(strerror(errno)) > 1000)
+		if (strlen(device) + 2 + strlen(strerror(errno)) + 1 < ERR_BUFLEN)
+			sprintf(errbuf, "%s: %s", device, strerror(errno));
+		else
 			sprintf(errbuf, _("%s: BAD ERROR, message is "
 						 "far too long"), device);
-		else {
-			errsv = errno;
-			sprintf(errbuf, "%s: %s", device,
-				       strerror(errsv));
-		}
-		errbuf[1024] = 0;
-		return (errbuf);
+		errbuf[ERR_BUFLEN] = 0;
+		return errbuf;
 	}
 
 	if (forked)
 		_exit(EXIT_SUCCESS);
-	return (NULL);
+	return NULL;
 }
-- 
1.9.2


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 08/12] wall: replace magic number by named value
  2014-05-11 19:26 [PATCH 01/12] tests: check /proc availability, and go-around if it is incomplete Sami Kerola
                   ` (5 preceding siblings ...)
  2014-05-11 19:26 ` [PATCH 07/12] term-utils: avoid error message string length couting errors Sami Kerola
@ 2014-05-11 19:26 ` Sami Kerola
  2014-05-11 19:26 ` [PATCH 09/12] setterm: remove unused code Sami Kerola
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 21+ messages in thread
From: Sami Kerola @ 2014-05-11 19:26 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 term-utils/wall.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/term-utils/wall.c b/term-utils/wall.c
index 1bae9d6..3031a0e 100644
--- a/term-utils/wall.c
+++ b/term-utils/wall.c
@@ -69,7 +69,10 @@
 #include "fileutils.h"
 #include "closestream.h"
 
-#define WRITE_TIME_OUT	300		/* in seconds */
+enum {
+	TERM_WIDTH = 79,
+	WRITE_TIME_OUT = 300		/* in seconds */
+};
 
 /* Function prototypes */
 static char *makemsg(char *fname, char **mvec, int mvecsz,
@@ -225,14 +228,14 @@ static char *makemsg(char *fname, char **mvec, int mvecsz,
 		 */
 		/* snprintf is not always available, but the sprintf's here
 		   will not overflow as long as %d takes at most 100 chars */
-		fprintf(fp, "\r%79s\r\n", " ");
+		fprintf(fp, "\r%*s\r\n", TERM_WIDTH, " ");
 		sprintf(lbuf, _("Broadcast message from %s@%s (%s) (%s):"),
 			      whom, hostname, where, date);
-		fprintf(fp, "%-79.79s\007\007\r\n", lbuf);
+		fprintf(fp, "%-*.*s\007\007\r\n", TERM_WIDTH, TERM_WIDTH, lbuf);
 		free(hostname);
 		free(date);
 	}
-	fprintf(fp, "%79s\r\n", " ");
+	fprintf(fp, "%*s\r\n", TERM_WIDTH, " ");
 
 	 if (mvec) {
 		/*
@@ -274,8 +277,8 @@ static char *makemsg(char *fname, char **mvec, int mvecsz,
 		 */
 		while (fgets(lbuf, line_max, stdin)) {
 			for (cnt = 0, p = lbuf; (ch = *p) != '\0'; ++p, ++cnt) {
-				if (cnt == 79 || ch == '\n') {
-					for (; cnt < 79; ++cnt)
+				if (cnt == TERM_WIDTH || ch == '\n') {
+					for (; cnt < TERM_WIDTH; ++cnt)
 						putc(' ', fp);
 					putc('\r', fp);
 					putc('\n', fp);
@@ -288,7 +291,7 @@ static char *makemsg(char *fname, char **mvec, int mvecsz,
 			}
 		}
 	}
-	fprintf(fp, "%79s\r\n", " ");
+	fprintf(fp, "%*s\r\n", TERM_WIDTH, " ");
 
 	free(lbuf);
 	rewind(fp);
-- 
1.9.2


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 09/12] setterm: remove unused code
  2014-05-11 19:26 [PATCH 01/12] tests: check /proc availability, and go-around if it is incomplete Sami Kerola
                   ` (6 preceding siblings ...)
  2014-05-11 19:26 ` [PATCH 08/12] wall: replace magic number by named value Sami Kerola
@ 2014-05-11 19:26 ` Sami Kerola
  2014-05-11 19:26 ` [PATCH 10/12] setterm: use string constant rather than #define Sami Kerola
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 21+ messages in thread
From: Sami Kerola @ 2014-05-11 19:26 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 term-utils/setterm.c | 71 +++-------------------------------------------------
 1 file changed, 3 insertions(+), 68 deletions(-)

diff --git a/term-utils/setterm.c b/term-utils/setterm.c
index f179ea8..01fe27e 100644
--- a/term-utils/setterm.c
+++ b/term-utils/setterm.c
@@ -140,12 +140,6 @@ extern int klogctl(int type, char *buf, int len);
 /* Non-standard return values. */
 #define EXIT_DUMPFILE	-1
 
-/* Keyboard types. */
-#define PC	 0
-#define OLIVETTI 1
-#define DUTCH    2
-#define EXTENDED 3
-
 /* Colors. */
 #define BLACK   0
 #define RED     1
@@ -173,16 +167,14 @@ extern int klogctl(int type, char *buf, int len);
 
 /* Control sequences. */
 #define ESC "\033"
-#define DCS "\033P"
-#define ST  "\033\\"
 
 /* Static variables. */
 
 /* Option flags.  Set if the option is to be invoked. */
 int opt_term, opt_reset, opt_initialize, opt_cursor;
-int opt_linewrap, opt_snow, opt_softscroll, opt_default, opt_foreground;
+int opt_linewrap, opt_default, opt_foreground;
 int opt_background, opt_bold, opt_blink, opt_reverse, opt_underline;
-int opt_store, opt_clear, opt_blank, opt_snap, opt_snapfile, opt_standout;
+int opt_store, opt_clear, opt_blank, opt_snap, opt_snapfile;
 int opt_append, opt_ulcolor, opt_hbcolor, opt_halfbright, opt_repeat;
 int opt_tabs, opt_clrtabs, opt_regtabs, opt_appcursorkeys, opt_inversescreen;
 int opt_msg, opt_msglevel, opt_powersave, opt_powerdown;
@@ -192,10 +184,9 @@ int opt_blength, opt_bfreq;
  * uniqueness.
  */
 char *opt_te_terminal_name;	/* Terminal name. */
-int opt_cu_on, opt_li_on, opt_sn_on, opt_so_on, opt_bo_on, opt_hb_on, opt_bl_on;
+int opt_cu_on, opt_li_on, opt_bo_on, opt_hb_on, opt_bl_on;
 int opt_re_on, opt_un_on, opt_rep_on, opt_appck_on, opt_invsc_on;
 int opt_msg_on;			/* Boolean switches. */
-int opt_ke_type;		/* Keyboard type. */
 int opt_fo_color, opt_ba_color;	/* Colors. */
 int opt_ul_color, opt_hb_color;
 int opt_cl_all;			/* Clear all or rest. */
@@ -203,7 +194,6 @@ int opt_bl_min;			/* Blank screen. */
 int opt_blength_l;
 int opt_bfreq_f;
 int opt_sn_num;			/* Snap screen. */
-int opt_st_attr;
 int opt_rt_len;			/* regular tab length */
 int opt_tb_array[161];		/* Array for tab list */
 int opt_msglevel_num;
@@ -456,27 +446,6 @@ parse_powersave(int argc, char **argv, int *option, int *opt_mode, int *bad_arg)
 	}
 }
 
-#if 0
-static void
-parse_standout(int argc, char *argv, int *option, int *opt_all, int *bad_arg) {
-	/* argc: Number of arguments for this option. */
-	/* argv: Arguments for this option. */
-	/* option: Clear flag to set. */
-	/* opt_all: Clear all switch to set or reset. */
-	/* bad_arg: Set to true if an error is detected. */
-
-/* Parse a -standout specification. */
-
-	if (argc > 1 || *option)
-		*bad_arg = TRUE;
-	*option = TRUE;
-	if (argc == 1)
-		*opt_all = atoi(argv[0]);
-	else
-		*opt_all = -1;
-}
-#endif
-
 static void
 parse_msglevel(int argc, char **argv, int *option, int *opt_all, int *bad_arg) {
 	/* argc: Number of arguments for this option. */
@@ -747,12 +716,6 @@ parse_option(char *option, int argc, char **argv, int *bad_arg) {
 		parse_switch(argc, argv, &opt_appcursorkeys, &opt_appck_on, bad_arg);
 	else if (STRCMP(option, "linewrap") == 0)
 		parse_switch(argc, argv, &opt_linewrap, &opt_li_on, bad_arg);
-#if 0
-	else if (STRCMP(option, "snow") == 0)
-		parse_switch(argc, argv, &opt_snow, &opt_sn_on, bad_arg);
-	else if (STRCMP(option, "softscroll") == 0)
-		parse_switch(argc, argv, &opt_softscroll, &opt_so_on, bad_arg);
-#endif
 	else if (STRCMP(option, "default") == 0)
 		parse_none(argc, argv, &opt_default, bad_arg);
 	else if (STRCMP(option, "foreground") == 0)
@@ -805,10 +768,6 @@ parse_option(char *option, int argc, char **argv, int *bad_arg) {
 		parse_blength(argc, argv, &opt_blength, &opt_blength_l, bad_arg);
 	else if (STRCMP(option, "bfreq") == 0)
 		parse_bfreq(argc, argv, &opt_bfreq, &opt_bfreq_f, bad_arg);
-#if 0
-	else if (STRCMP(option, "standout") == 0)
-		parse_standout(argc, argv, &opt_standout, &opt_st_attr, bad_arg);
-#endif
 	else if (STRCMP(option, "version") == 0) {
 		printf(_("%s from %s\n"), program_invocation_short_name,
 					  PACKAGE_STRING);
@@ -884,24 +843,6 @@ perform_sequence(int vcterm) {
 			printf("\033[?1l");
 	}
 
-#if 0
-	/* -snow [on|off].  Vc only. */
-	if (opt_snow && vcterm) {
-		if (opt_sn_on)
-			printf("%s%s%s", DCS, "snow.on", ST);
-		else
-			printf("%s%s%s", DCS, "snow.off", ST);
-	}
-
-	/* -softscroll [on|off].  Vc only. */
-	if (opt_softscroll && vcterm) {
-		if (opt_so_on)
-			printf("%s%s%s", DCS, "softscroll.on", ST);
-		else
-			printf("%s%s%s", DCS, "softscroll.off", ST);
-	}
-#endif
-
 	/* -default.  Vc sets default rendition, otherwise clears all
 	 * attributes.
 	 */
@@ -1100,12 +1041,6 @@ perform_sequence(int vcterm) {
 		printf("\033[14;%d]", opt_pd_min);
 	}
 
-#if 0
-	/* -standout [num]. */
-	if (opt_standout)
-		/* nothing */;
-#endif
-
 	/* -snap [1-NR_CONS]. */
 	if (opt_snap || opt_append) {
 		FILE *F;
-- 
1.9.2


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 10/12] setterm: use string constant rather than #define
  2014-05-11 19:26 [PATCH 01/12] tests: check /proc availability, and go-around if it is incomplete Sami Kerola
                   ` (7 preceding siblings ...)
  2014-05-11 19:26 ` [PATCH 09/12] setterm: remove unused code Sami Kerola
@ 2014-05-11 19:26 ` Sami Kerola
  2014-05-12 12:07   ` Karel Zak
  2014-05-11 19:26 ` [PATCH 11/12] setterm: convert various constant number definitions to enums Sami Kerola
                   ` (3 subsequent siblings)
  12 siblings, 1 reply; 21+ messages in thread
From: Sami Kerola @ 2014-05-11 19:26 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

There is no need to repeat same string in compiled code everywhere.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 term-utils/setterm.c | 47 +++++++++++++++++++++++------------------------
 1 file changed, 23 insertions(+), 24 deletions(-)

diff --git a/term-utils/setterm.c b/term-utils/setterm.c
index 01fe27e..ef820b3 100644
--- a/term-utils/setterm.c
+++ b/term-utils/setterm.c
@@ -165,9 +165,6 @@ extern int klogctl(int type, char *buf, int len);
 # define TIOCL_BLANKEDSCREEN	15	/* return which vt was blanked */
 #endif
 
-/* Control sequences. */
-#define ESC "\033"
-
 /* Static variables. */
 
 /* Option flags.  Set if the option is to be invoked. */
@@ -796,6 +793,8 @@ static char *ti_entry(const char *name) {
 
 static void
 perform_sequence(int vcterm) {
+	static const char *ESC = "\033";
+
 	/* vcterm: Set if terminal is a virtual console. */
 
 	int result;
@@ -822,25 +821,25 @@ perform_sequence(int vcterm) {
 	/* -linewrap [on|off]. Vc only (vt102) */
 	if (opt_linewrap && vcterm) {
 		if (opt_li_on)
-			printf("\033[?7h");
+			printf("%s[?7h", ESC);
 		else
-			printf("\033[?7l");
+			printf("%s[?7l", ESC);
 	}
 
 	/* -repeat [on|off]. Vc only (vt102) */
 	if (opt_repeat && vcterm) {
 		if (opt_rep_on)
-			printf("\033[?8h");
+			printf("%s[?8h", ESC);
 		else
-			printf("\033[?8l");
+			printf("%s[?8l", ESC);
 	}
 
 	/* -appcursorkeys [on|off]. Vc only (vt102) */
 	if (opt_appcursorkeys && vcterm) {
 		if (opt_appck_on)
-			printf("\033[?1h");
+			printf("%s[?1h", ESC);
 		else
-			printf("\033[?1l");
+			printf("%s[?1l", ESC);
 	}
 
 	/* -default.  Vc sets default rendition, otherwise clears all
@@ -848,7 +847,7 @@ perform_sequence(int vcterm) {
 	 */
 	if (opt_default) {
 		if (vcterm)
-			printf("\033[0m");
+			printf("%s[0m", ESC);
 		else
 			putp(ti_entry("sgr0"));
 	}
@@ -871,14 +870,14 @@ perform_sequence(int vcterm) {
 	 * Vc only.
 	 */
 	if (opt_ulcolor && vcterm) {
-		printf("\033[1;%d]", opt_ul_color);
+		printf("%s[1;%d]", ESC, opt_ul_color);
 	}
 
 	/* -hbcolor black|red|green|yellow|blue|magenta|cyan|white|default.
 	 * Vc only.
 	 */
 	if (opt_hbcolor && vcterm) {
-		printf("\033[2;%d]", opt_hb_color);
+		printf("%s[2;%d]", ESC, opt_hb_color);
 	}
 
 	/* -inversescreen [on|off].  Vc only (vt102).
@@ -886,9 +885,9 @@ perform_sequence(int vcterm) {
 	if (opt_inversescreen) {
 		if (vcterm) {
 			if (opt_invsc_on)
-				printf("\033[?5h");
+				printf("%s[?5h", ESC);
 			else
-				printf("\033[?5l");
+				printf("%s[?5l", ESC);
 		}
 	}
 
@@ -958,7 +957,7 @@ perform_sequence(int vcterm) {
 
 	/* -store.  Vc only. */
 	if (opt_store && vcterm) {
-		printf("\033[8]");
+		printf("%s[8]", ESC);
 	}
 
 	/* -clear [all|rest]. */
@@ -977,7 +976,7 @@ perform_sequence(int vcterm) {
 			show_tabs();
 		else {
 			for(i=0; opt_tb_array[i] > 0; i++)
-				printf("\033[%dG\033H", opt_tb_array[i]);
+				printf("%s[%dG%sH", ESC, opt_tb_array[i], ESC);
 			putchar('\r');
 		}
 	}
@@ -987,10 +986,10 @@ perform_sequence(int vcterm) {
 		int i;
 
 		if (opt_tb_array[0] == -1)
-			printf("\033[3g");
+			printf("%s[3g", ESC);
 		else
 			for(i=0; opt_tb_array[i] > 0; i++)
-				printf("\033[%dG\033[g", opt_tb_array[i]);
+				printf("%s[%dG%s[g", ESC, opt_tb_array[i], ESC);
 		putchar('\r');
 	}
 
@@ -998,16 +997,16 @@ perform_sequence(int vcterm) {
 	if (opt_regtabs && vcterm) {
 		int i;
 
-		printf("\033[3g\r");
+		printf("%s[3g\r", ESC);
 		for(i=opt_rt_len+1; i<=160; i+=opt_rt_len)
-			printf("\033[%dC\033H",opt_rt_len);
+			printf("%s[%dC%sH", ESC, opt_rt_len, ESC);
 		putchar('\r');
 	}
 
 	/* -blank [0-60]. */
 	if (opt_blank && vcterm) {
 		if (opt_bl_min >= 0)
-			printf("\033[9;%d]", opt_bl_min);
+			printf("%s[9;%d]", ESC, opt_bl_min);
 		else if (opt_bl_min == BLANKSCREEN) {
 			char ioctlarg = TIOCL_BLANKSCREEN;
 			if (ioctl(0,TIOCLINUX,&ioctlarg))
@@ -1038,7 +1037,7 @@ perform_sequence(int vcterm) {
 
 	/* -powerdown [0-60]. */
 	if (opt_powerdown) {
-		printf("\033[14;%d]", opt_pd_min);
+		printf("%s[14;%d]", ESC, opt_pd_min);
 	}
 
 	/* -snap [1-NR_CONS]. */
@@ -1077,12 +1076,12 @@ perform_sequence(int vcterm) {
 
 	/* -blength [0-2000] */
 	if (opt_blength && vcterm) {
-		printf("\033[11;%d]", opt_blength_l);
+		printf("%s[11;%d]", ESC, opt_blength_l);
 	}
 
 	/* -bfreq freqnumber */
 	if (opt_bfreq && vcterm) {
-		printf("\033[10;%d]", opt_bfreq_f);
+		printf("%s[10;%d]", ESC, opt_bfreq_f);
 	}
 
 }
-- 
1.9.2


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 11/12] setterm: convert various constant number definitions to enums
  2014-05-11 19:26 [PATCH 01/12] tests: check /proc availability, and go-around if it is incomplete Sami Kerola
                   ` (8 preceding siblings ...)
  2014-05-11 19:26 ` [PATCH 10/12] setterm: use string constant rather than #define Sami Kerola
@ 2014-05-11 19:26 ` Sami Kerola
  2014-05-11 19:26 ` [PATCH 12/12] setterm: convert remaining magic values to symbolic references Sami Kerola
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 21+ messages in thread
From: Sami Kerola @ 2014-05-11 19:26 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

The enum strings are visible when using debugger.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 term-utils/setterm.c | 46 ++++++++++++++++++++++++++--------------------
 1 file changed, 26 insertions(+), 20 deletions(-)

diff --git a/term-utils/setterm.c b/term-utils/setterm.c
index ef820b3..2de555e 100644
--- a/term-utils/setterm.c
+++ b/term-utils/setterm.c
@@ -141,28 +141,34 @@ extern int klogctl(int type, char *buf, int len);
 #define EXIT_DUMPFILE	-1
 
 /* Colors. */
-#define BLACK   0
-#define RED     1
-#define GREEN   2
-#define YELLOW  3
-#define BLUE    4
-#define MAGENTA 5
-#define CYAN    6
-#define WHITE   7
-#define GREY	8
-#define DEFAULT 9
+enum {
+	BLACK = 0,
+	RED,
+	GREEN,
+	YELLOW,
+	BLUE,
+	MAGENTA,
+	CYAN,
+	WHITE,
+	GREY,
+	DEFAULT
+};
 
 /* Blank commands */
-#define BLANKSCREEN	-1
-#define UNBLANKSCREEN	-2
-#define BLANKEDSCREEN	-3
+enum {
+	BLANKSCREEN	= -1,
+	UNBLANKSCREEN	= -2,
+	BLANKEDSCREEN	= -3
+};
 
 /* <linux/tiocl.h> fallback */
 #ifndef TIOCL_BLANKSCREEN
-# define TIOCL_UNBLANKSCREEN	4       /* unblank screen */
-# define TIOCL_SETVESABLANK	10      /* set vesa blanking mode */
-# define TIOCL_BLANKSCREEN	14	/* keep screen blank even if a key is pressed */
-# define TIOCL_BLANKEDSCREEN	15	/* return which vt was blanked */
+enum {
+	TIOCL_UNBLANKSCREEN	=  4,	/* unblank screen */
+	TIOCL_SETVESABLANK	= 10,	/* set vesa blanking mode */
+	TIOCL_BLANKSCREEN	= 14,	/* keep screen blank even if a key is pressed */
+	TIOCL_BLANKEDSCREEN	= 15	/* return which vt was blanked */
+};
 #endif
 
 /* Static variables. */
@@ -298,7 +304,7 @@ par_color(int argc, char **argv, int *option, int *opt_color, int *bad_arg) {
 		else
 			*bad_arg = TRUE;
 
-		if(*opt_color < 0 || *opt_color > 9 || *opt_color == 8)
+		if(*opt_color < BLACK || DEFAULT < *opt_color || *opt_color == GREY)
 			*bad_arg = TRUE;
 	}
 }
@@ -319,7 +325,7 @@ par_color2(int argc, char **argv, int *option, int *opt_color, int *bad_arg) {
 	*opt_color = 0;
 	if (argc == 2) {
 		if (strcmp(argv[0], "bright") == 0)
-			*opt_color = 8;
+			*opt_color = GREY;
 		else {
 			*bad_arg = TRUE;
 			return;
@@ -354,7 +360,7 @@ par_color2(int argc, char **argv, int *option, int *opt_color, int *bad_arg) {
 			*opt_color = atoi(argv[argc-1]);
 		else
 			*bad_arg = TRUE;
-		if(*opt_color < 0 || *opt_color > 15)
+		if(*opt_color < BLACK || DEFAULT < *opt_color )
 			*bad_arg = TRUE;
 	}
 }
-- 
1.9.2


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 12/12] setterm: convert remaining magic values to symbolic references
  2014-05-11 19:26 [PATCH 01/12] tests: check /proc availability, and go-around if it is incomplete Sami Kerola
                   ` (9 preceding siblings ...)
  2014-05-11 19:26 ` [PATCH 11/12] setterm: convert various constant number definitions to enums Sami Kerola
@ 2014-05-11 19:26 ` Sami Kerola
  2014-05-12 12:10   ` Karel Zak
  2014-05-12  7:05 ` [PATCH 01/12] tests: check /proc availability, and go-around if it is incomplete Bernhard Voelker
  2014-05-12 12:01 ` Karel Zak
  12 siblings, 1 reply; 21+ messages in thread
From: Sami Kerola @ 2014-05-11 19:26 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 term-utils/setterm.c | 65 ++++++++++++++++++++++++++++++++++++----------------
 1 file changed, 45 insertions(+), 20 deletions(-)

diff --git a/term-utils/setterm.c b/term-utils/setterm.c
index 2de555e..5950d2a 100644
--- a/term-utils/setterm.c
+++ b/term-utils/setterm.c
@@ -171,6 +171,31 @@ enum {
 };
 #endif
 
+/* Powersave modes */
+enum {
+	VESA_BLANK_MODE_OFF = 0,
+	VESA_BLANK_MODE_SUSPENDV,
+	VESA_BLANK_MODE_SUSPENDH,
+	VESA_BLANK_MODE_POWERDOWN
+};
+
+/* klogctl() actions */
+enum {
+	SYSLOG_ACTION_CONSOLE_OFF	= 6,
+	SYSLOG_ACTION_CONSOLE_ON	= 7,
+	SYSLOG_ACTION_CONSOLE_LEVEL	= 8
+};
+
+/* Various numbers  */
+enum {
+	CONSOLE_LEVEL_MIN = 1,
+	CONSOLE_LEVEL_MAX = 8,
+	DEFAULT_TAB_LEN = 8,
+	BLANK_MAX = 60,
+	TABS_MAX = 160,
+	BLENGTH_MAX = 2000,
+};
+
 /* Static variables. */
 
 /* Option flags.  Set if the option is to be invoked. */
@@ -198,7 +223,7 @@ int opt_blength_l;
 int opt_bfreq_f;
 int opt_sn_num;			/* Snap screen. */
 int opt_rt_len;			/* regular tab length */
-int opt_tb_array[161];		/* Array for tab list */
+int opt_tb_array[TABS_MAX + 1];	/* Array for tab list */
 int opt_msglevel_num;
 int opt_ps_mode, opt_pd_min;	/* powersave mode/powerdown time */
 
@@ -410,7 +435,7 @@ parse_blank(int argc, char **argv, int *option, int *opt_all, int *bad_arg) {
 			*opt_all = UNBLANKSCREEN;
 		else {
 			*opt_all = atoi(argv[0]);
-			if ((*opt_all > 60) || (*opt_all < 0))
+			if (*opt_all < 0 || BLANK_MAX < *opt_all)
 				*bad_arg = TRUE;
 		}
 	} else {
@@ -433,19 +458,19 @@ parse_powersave(int argc, char **argv, int *option, int *opt_mode, int *bad_arg)
 	*option = TRUE;
 	if (argc == 1) {
 		if (strcmp(argv[0], "on") == 0)
-			*opt_mode = 1;
+			*opt_mode = VESA_BLANK_MODE_SUSPENDV;
 		else if (strcmp(argv[0], "vsync") == 0)
-			*opt_mode = 1;
+			*opt_mode = VESA_BLANK_MODE_SUSPENDV;
 		else if (strcmp(argv[0], "hsync") == 0)
-			*opt_mode = 2;
+			*opt_mode = VESA_BLANK_MODE_SUSPENDH;
 		else if (strcmp(argv[0], "powerdown") == 0)
-			*opt_mode = 3;
+			*opt_mode = VESA_BLANK_MODE_POWERDOWN;
 		else if (strcmp(argv[0], "off") == 0)
-			*opt_mode = 0;
+			*opt_mode = VESA_BLANK_MODE_OFF;
 		else
 			*bad_arg = TRUE;
 	} else {
-		*opt_mode = 0;
+		*opt_mode = VESA_BLANK_MODE_OFF;
 	}
 }
 
@@ -462,7 +487,7 @@ parse_msglevel(int argc, char **argv, int *option, int *opt_all, int *bad_arg) {
 	*option = TRUE;
 	if (argc == 1) {
 		*opt_all = atoi(argv[0]);
-		if (*opt_all < 0 || *opt_all > 8)
+		if (*opt_all < CONSOLE_LEVEL_MIN || CONSOLE_LEVEL_MAX <  *opt_all)
 			*bad_arg = TRUE;
 	} else {
 		*opt_all = -1;
@@ -517,13 +542,13 @@ parse_tabs(int argc, char **argv, int *option, int *tab_array, int *bad_arg) {
 	/* tab_array: Array of tabs */
 	/* bad_arg: Set to true if an error is detected. */
 
-	if (*option || argc > 160)
+	if (*option || TABS_MAX < argc)
 		*bad_arg = TRUE;
 	*option = TRUE;
 	tab_array[argc] = -1;
 	while(argc--) {
 		tab_array[argc] = atoi(argv[argc]);
-		if(tab_array[argc] < 1 || tab_array[argc] > 160) {
+		if (tab_array[argc] < 1 || TABS_MAX < tab_array[argc]) {
 			*bad_arg = TRUE;
 			return;
 		}
@@ -538,7 +563,7 @@ parse_clrtabs(int argc, char **argv, int *option, int *tab_array, int *bad_arg)
 	/* tab_array: Array of tabs */
 	/* bad_arg: Set to true if an error is detected. */
 
-	if (*option || argc > 160)
+	if (*option || TABS_MAX < argc)
 		*bad_arg = TRUE;
 	*option = TRUE;
 	if(argc == 0) {
@@ -548,7 +573,7 @@ parse_clrtabs(int argc, char **argv, int *option, int *tab_array, int *bad_arg)
 	tab_array[argc] = -1;
 	while(argc--) {
 		tab_array[argc] = atoi(argv[argc]);
-		if(tab_array[argc] < 1 || tab_array[argc] > 160) {
+		if(tab_array[argc] < 1 || TABS_MAX < tab_array[argc]) {
 			*bad_arg = TRUE;
 			return;
 		}
@@ -567,11 +592,11 @@ parse_regtabs(int argc, char **argv, int *option, int *opt_len, int *bad_arg) {
 		*bad_arg = TRUE;
 	*option = TRUE;
 	if(argc == 0) {
-		*opt_len = 8;
+		*opt_len = DEFAULT_TAB_LEN;
 		return;
 	}
 	*opt_len = atoi(argv[0]);
-	if(*opt_len < 1 || *opt_len > 160) {
+	if(*opt_len < 1 || TABS_MAX < *opt_len) {
 		*bad_arg = TRUE;
 		return;
 	}
@@ -593,7 +618,7 @@ parse_blength(int argc, char **argv, int *option, int *opt_all, int *bad_arg) {
 	*option = TRUE;
 	if (argc == 1) {
 		*opt_all = atoi(argv[0]);
-		if (*opt_all > 2000)
+		if (BLENGTH_MAX < *opt_all)
 			*bad_arg = TRUE;
 	} else {
 		*opt_all = 0;
@@ -1004,7 +1029,7 @@ perform_sequence(int vcterm) {
 		int i;
 
 		printf("%s[3g\r", ESC);
-		for(i=opt_rt_len+1; i<=160; i+=opt_rt_len)
+		for(i=opt_rt_len+1; i<=TABS_MAX; i+=opt_rt_len)
 			printf("%s[%dC%sH", ESC, opt_rt_len, ESC);
 		putchar('\r');
 	}
@@ -1063,10 +1088,10 @@ perform_sequence(int vcterm) {
 	if (opt_msg && vcterm) {
 		if (opt_msg_on)
 			/* 7 -- Enable printk's to console */
-			result = klogctl(7, NULL, 0);
+			result = klogctl(SYSLOG_ACTION_CONSOLE_ON, NULL, 0);
 		else
 			/*  6 -- Disable printk's to console */
-			result = klogctl(6, NULL, 0);
+			result = klogctl(SYSLOG_ACTION_CONSOLE_OFF, NULL, 0);
 
 		if (result != 0)
 			warn(_("klogctl error"));
@@ -1075,7 +1100,7 @@ perform_sequence(int vcterm) {
 	/* -msglevel [0-8] */
 	if (opt_msglevel && vcterm) {
 		/* 8 -- Set level of messages printed to console */
-		result = klogctl(8, NULL, opt_msglevel_num);
+		result = klogctl(SYSLOG_ACTION_CONSOLE_LEVEL, NULL, opt_msglevel_num);
 		if (result != 0)
 			warn(_("klogctl error"));
 	}
-- 
1.9.2


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [PATCH 01/12] tests: check /proc availability, and go-around if it is incomplete
  2014-05-11 19:26 [PATCH 01/12] tests: check /proc availability, and go-around if it is incomplete Sami Kerola
                   ` (10 preceding siblings ...)
  2014-05-11 19:26 ` [PATCH 12/12] setterm: convert remaining magic values to symbolic references Sami Kerola
@ 2014-05-12  7:05 ` Bernhard Voelker
  2014-05-12  9:13   ` Sami Kerola
  2014-05-12 11:06   ` Karel Zak
  2014-05-12 12:01 ` Karel Zak
  12 siblings, 2 replies; 21+ messages in thread
From: Bernhard Voelker @ 2014-05-12  7:05 UTC (permalink / raw)
  To: Sami Kerola, util-linux; +Cc: Ruediger Meier

On 05/11/2014 09:26 PM, Sami Kerola wrote:
> diff --git a/tests/ts/kill/kill_functions.sh b/tests/ts/kill/kill_functions.sh
> index 73fff05..a2a2483 100644
> --- a/tests/ts/kill/kill_functions.sh
> +++ b/tests/ts/kill/kill_functions.sh
> @@ -1,3 +1,5 @@
> +# kill tests, or command, will not when /proc is missing.
> +test /proc || ts_skip "/proc not available"

Ahem, this only ensures that '/proc' is a string, nothing else ...


>  # unfortunately we are using gawk features
>  type gawk >/dev/null 2>&1 || ts_skip "cannot find gawk"
> @@ -8,6 +10,17 @@ function check_test_sigreceive {
>  	local pid=$1
>  
>  	for i in 0.01 0.1 1 1 1 1; do
> +		if [ ! -f /proc/$pid/status ]; then
> +			# The /proc exists, but not status file. Because
> +			# the process already started it is unlikely the
> +			# file would appear after any amount of waiting.
> +			# Try to sleep for moment and hopefully
> +			# test_sigreceive is ready to be killed.
> +			echo "kill_functions.sh: /proc/$pid/status: No such file or directory"
> +			sleep 2
> +			rc=1
> +			break
> +		fi
>  		gawk 'BEGIN { retval=1 }
>  		/^SigCgt/ {
>  			lbyte = strtonum("0x" substr($2, 16, 16))
> 

Seeing all this /proc stuff going into the tests - it now even
requires gawk - I still personally think that a simple witness
file would have done it.
So Karel, if you really prefer this, then I'm okay with it, of course.

Have a nice day,
Berny

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 01/12] tests: check /proc availability, and go-around if it is incomplete
  2014-05-12  7:05 ` [PATCH 01/12] tests: check /proc availability, and go-around if it is incomplete Bernhard Voelker
@ 2014-05-12  9:13   ` Sami Kerola
  2014-05-12 11:06   ` Karel Zak
  1 sibling, 0 replies; 21+ messages in thread
From: Sami Kerola @ 2014-05-12  9:13 UTC (permalink / raw)
  To: Bernhard Voelker; +Cc: util-linux, Ruediger Meier

On 12 May 2014 08:05, Bernhard Voelker <mail@bernhard-voelker.de> wrote:
> On 05/11/2014 09:26 PM, Sami Kerola wrote:
>> diff --git a/tests/ts/kill/kill_functions.sh b/tests/ts/kill/kill_functions.sh
>> index 73fff05..a2a2483 100644
>> --- a/tests/ts/kill/kill_functions.sh
>> +++ b/tests/ts/kill/kill_functions.sh
>> @@ -1,3 +1,5 @@
>> +# kill tests, or command, will not when /proc is missing.
>> +test /proc || ts_skip "/proc not available"
>
> Ahem, this only ensures that '/proc' is a string, nothing else ...

Hi Berny,

Thank you for getting rid of silly mistake. Fix is available in my git.

https://github.com/kerolasa/lelux-utiliteetit/commit/04af69d0ab20f337a40e72d501f13977d20e4013

>>  # unfortunately we are using gawk features
>>  type gawk >/dev/null 2>&1 || ts_skip "cannot find gawk"
>> @@ -8,6 +10,17 @@ function check_test_sigreceive {
>>       local pid=$1
>>
>>       for i in 0.01 0.1 1 1 1 1; do
>> +             if [ ! -f /proc/$pid/status ]; then
>> +                     # The /proc exists, but not status file. Because
>> +                     # the process already started it is unlikely the
>> +                     # file would appear after any amount of waiting.
>> +                     # Try to sleep for moment and hopefully
>> +                     # test_sigreceive is ready to be killed.
>> +                     echo "kill_functions.sh: /proc/$pid/status: No such file or directory"
>> +                     sleep 2
>> +                     rc=1
>> +                     break
>> +             fi
>>               gawk 'BEGIN { retval=1 }
>>               /^SigCgt/ {
>>                       lbyte = strtonum("0x" substr($2, 16, 16))
>>
>
> Seeing all this /proc stuff going into the tests - it now even
> requires gawk - I still personally think that a simple witness
> file would have done it.
> So Karel, if you really prefer this, then I'm okay with it, of course.

With witness file comes the issue of who can write and where when the
check that runs as root does the 'nobody' process killing. Is that
issue more or less simple to go-around than status file parsing. I'm
not sure, but I am getting a bit tired of these checks.

BTW I had no idea util-linux is tested in environments that something
else but gawk as default awk.

-- 
Sami Kerola
http://www.iki.fi/kerolasa/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 01/12] tests: check /proc availability, and go-around if it is incomplete
  2014-05-12  7:05 ` [PATCH 01/12] tests: check /proc availability, and go-around if it is incomplete Bernhard Voelker
  2014-05-12  9:13   ` Sami Kerola
@ 2014-05-12 11:06   ` Karel Zak
  1 sibling, 0 replies; 21+ messages in thread
From: Karel Zak @ 2014-05-12 11:06 UTC (permalink / raw)
  To: Bernhard Voelker; +Cc: Sami Kerola, util-linux, Ruediger Meier

On Mon, May 12, 2014 at 09:05:34AM +0200, Bernhard Voelker wrote:
> On 05/11/2014 09:26 PM, Sami Kerola wrote:
> > diff --git a/tests/ts/kill/kill_functions.sh b/tests/ts/kill/kill_functions.sh
> > index 73fff05..a2a2483 100644
> > --- a/tests/ts/kill/kill_functions.sh
> > +++ b/tests/ts/kill/kill_functions.sh
> > @@ -1,3 +1,5 @@
> > +# kill tests, or command, will not when /proc is missing.
> > +test /proc || ts_skip "/proc not available"
> 
> Ahem, this only ensures that '/proc' is a string, nothing else ...

 Fixed.

> >  # unfortunately we are using gawk features
> >  type gawk >/dev/null 2>&1 || ts_skip "cannot find gawk"
> > @@ -8,6 +10,17 @@ function check_test_sigreceive {
> >  	local pid=$1
> >  
> >  	for i in 0.01 0.1 1 1 1 1; do
> > +		if [ ! -f /proc/$pid/status ]; then
> > +			# The /proc exists, but not status file. Because
> > +			# the process already started it is unlikely the
> > +			# file would appear after any amount of waiting.
> > +			# Try to sleep for moment and hopefully
> > +			# test_sigreceive is ready to be killed.
> > +			echo "kill_functions.sh: /proc/$pid/status: No such file or directory"
> > +			sleep 2
> > +			rc=1
> > +			break
> > +		fi
> >  		gawk 'BEGIN { retval=1 }
> >  		/^SigCgt/ {
> >  			lbyte = strtonum("0x" substr($2, 16, 16))
> > 
> 
> Seeing all this /proc stuff going into the tests - it now even
> requires gawk - I still personally think that a simple witness
> file would have done it.
> So Karel, if you really prefer this, then I'm okay with it, of course.

The dependence on gawk is not nice thing, I have modified the function
to use simple awk print stuff and shell to convert & check sigmask.

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 01/12] tests: check /proc availability, and go-around if it is incomplete
  2014-05-11 19:26 [PATCH 01/12] tests: check /proc availability, and go-around if it is incomplete Sami Kerola
                   ` (11 preceding siblings ...)
  2014-05-12  7:05 ` [PATCH 01/12] tests: check /proc availability, and go-around if it is incomplete Bernhard Voelker
@ 2014-05-12 12:01 ` Karel Zak
  12 siblings, 0 replies; 21+ messages in thread
From: Karel Zak @ 2014-05-12 12:01 UTC (permalink / raw)
  To: Sami Kerola; +Cc: util-linux, Ruediger Meier

On Sun, May 11, 2014 at 08:26:38PM +0100, Sami Kerola wrote:
>  tests/ts/kill/kill_functions.sh | 13 +++++++++++++
>  1 file changed, 13 insertions(+)

 Fixed & merged, but I have removed the gawk-only code.

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 07/12] term-utils: avoid error message string length couting errors
  2014-05-11 19:26 ` [PATCH 07/12] term-utils: avoid error message string length couting errors Sami Kerola
@ 2014-05-12 12:05   ` Karel Zak
  0 siblings, 0 replies; 21+ messages in thread
From: Karel Zak @ 2014-05-12 12:05 UTC (permalink / raw)
  To: Sami Kerola; +Cc: util-linux

On Sun, May 11, 2014 at 08:26:44PM +0100, Sami Kerola wrote:
> diff --git a/term-utils/ttymsg.c b/term-utils/ttymsg.c
> index fb2614f..3a2565d 100644
> --- a/term-utils/ttymsg.c
> +++ b/term-utils/ttymsg.c
> @@ -58,6 +58,8 @@
>  #include "pathnames.h"
>  #include "ttymsg.h"
>  
> +enum { ERR_BUFLEN = MAXNAMLEN + 1024 };

 Please, don't use enum in this way, just

    #define ERR_BUFLEN  ...

>  	if (strlen(line) + sizeof(_PATH_DEV) + 1 > sizeof(device)) {
>  		sprintf(errbuf, _("excessively long line arg"));
> -		return (errbuf);
> +		return errbuf;
>  	}

 I have fixed the code to use snprintf() everywhere and to check
 snprintf() return code, that's better than the crazy strlen()+...
 check. 
 
 libc is smart enough to help us.

> +		errbuf[ERR_BUFLEN] = 0;

 Are you sure? :-)

 Fixed and merged.

    Karel


-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 10/12] setterm: use string constant rather than #define
  2014-05-11 19:26 ` [PATCH 10/12] setterm: use string constant rather than #define Sami Kerola
@ 2014-05-12 12:07   ` Karel Zak
  0 siblings, 0 replies; 21+ messages in thread
From: Karel Zak @ 2014-05-12 12:07 UTC (permalink / raw)
  To: Sami Kerola; +Cc: util-linux

On Sun, May 11, 2014 at 08:26:47PM +0100, Sami Kerola wrote:
> -/* Control sequences. */
> -#define ESC "\033"
> -
>  /* Static variables. */
>  
>  /* Option flags.  Set if the option is to be invoked. */
> @@ -796,6 +793,8 @@ static char *ti_entry(const char *name) {
>  
>  static void
>  perform_sequence(int vcterm) {
> +	static const char *ESC = "\033";

Sorry, but this is really premature optimization, \033 is just one char.

>  	/* vcterm: Set if terminal is a virtual console. */
>  
>  	int result;
> @@ -822,25 +821,25 @@ perform_sequence(int vcterm) {
>  	/* -linewrap [on|off]. Vc only (vt102) */
>  	if (opt_linewrap && vcterm) {
>  		if (opt_li_on)
> -			printf("\033[?7h");
> +			printf("%s[?7h", ESC);

  fputs("\033[?7h", stdout);

is the right, simple and fast way.

Fixed and merged.

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 12/12] setterm: convert remaining magic values to symbolic references
  2014-05-11 19:26 ` [PATCH 12/12] setterm: convert remaining magic values to symbolic references Sami Kerola
@ 2014-05-12 12:10   ` Karel Zak
  2014-05-12 14:53     ` Sami Kerola
  0 siblings, 1 reply; 21+ messages in thread
From: Karel Zak @ 2014-05-12 12:10 UTC (permalink / raw)
  To: Sami Kerola; +Cc: util-linux

On Sun, May 11, 2014 at 08:26:49PM +0100, Sami Kerola wrote:
> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
> ---
>  term-utils/setterm.c | 65 ++++++++++++++++++++++++++++++++++++----------------
>  1 file changed, 45 insertions(+), 20 deletions(-)
> 
> diff --git a/term-utils/setterm.c b/term-utils/setterm.c
> index 2de555e..5950d2a 100644
> --- a/term-utils/setterm.c
> +++ b/term-utils/setterm.c
> @@ -171,6 +171,31 @@ enum {
>  };
>  #endif
>  
> +/* Powersave modes */
> +enum {
> +	VESA_BLANK_MODE_OFF = 0,
> +	VESA_BLANK_MODE_SUSPENDV,
> +	VESA_BLANK_MODE_SUSPENDH,
> +	VESA_BLANK_MODE_POWERDOWN
> +};
> +
> +/* klogctl() actions */
> +enum {
> +	SYSLOG_ACTION_CONSOLE_OFF	= 6,
> +	SYSLOG_ACTION_CONSOLE_ON	= 7,
> +	SYSLOG_ACTION_CONSOLE_LEVEL	= 8
> +};

 OK.

> +/* Various numbers  */
> +enum {
> +	CONSOLE_LEVEL_MIN = 1,
> +	CONSOLE_LEVEL_MAX = 8,
> +	DEFAULT_TAB_LEN = 8,
> +	BLANK_MAX = 60,
> +	TABS_MAX = 160,
> +	BLENGTH_MAX = 2000,
> +};

 Please, use enum {} to group together things which have any relation,
 otherwise use #define.

 Fixed and merged.

 Applied all patches in the patchset, thanks.

    Karel


-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 02/12] cytune: remove from util-linux
  2014-05-11 19:26 ` [PATCH 02/12] cytune: remove from util-linux Sami Kerola
@ 2014-05-12 12:11   ` Karel Zak
  0 siblings, 0 replies; 21+ messages in thread
From: Karel Zak @ 2014-05-12 12:11 UTC (permalink / raw)
  To: Sami Kerola; +Cc: util-linux

On Sun, May 11, 2014 at 08:26:39PM +0100, Sami Kerola wrote:
> Assumption is there are not many who need this tool.  Whom ever they
> might be the recommendation is to use the command from old util-linux
> release.  Second reason to removal is difficulty to test hardware
> specific command when none of the active project members does not seem to
> have such.  Basically the command has reached dead end what comes to
> maintainability of it.

 OK :-)

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 12/12] setterm: convert remaining magic values to symbolic references
  2014-05-12 12:10   ` Karel Zak
@ 2014-05-12 14:53     ` Sami Kerola
  0 siblings, 0 replies; 21+ messages in thread
From: Sami Kerola @ 2014-05-12 14:53 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux

On 12 May 2014 13:10, Karel Zak <kzak@redhat.com> wrote:
>  Please, use enum {} to group together things which have any relation,
>  otherwise use #define.
>
>  Fixed and merged.

Thanks for review & advice, I'll try to better changes in future.

>  Applied all patches in the patchset, thanks.

Which brings to me to generic FYI; I'll work more with setterm(1) this week.

-- 
Sami Kerola
http://www.iki.fi/kerolasa/

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2014-05-12 14:53 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-11 19:26 [PATCH 01/12] tests: check /proc availability, and go-around if it is incomplete Sami Kerola
2014-05-11 19:26 ` [PATCH 02/12] cytune: remove from util-linux Sami Kerola
2014-05-12 12:11   ` Karel Zak
2014-05-11 19:26 ` [PATCH 03/12] blkid: remove unused variable Sami Kerola
2014-05-11 19:26 ` [PATCH 04/12] logger: fail when io vector number exceeds maximum Sami Kerola
2014-05-11 19:26 ` [PATCH 05/12] logger: check numeric priority and facility input values Sami Kerola
2014-05-11 19:26 ` [PATCH 06/12] build-sys: remove unnecessary void casts Sami Kerola
2014-05-11 19:26 ` [PATCH 07/12] term-utils: avoid error message string length couting errors Sami Kerola
2014-05-12 12:05   ` Karel Zak
2014-05-11 19:26 ` [PATCH 08/12] wall: replace magic number by named value Sami Kerola
2014-05-11 19:26 ` [PATCH 09/12] setterm: remove unused code Sami Kerola
2014-05-11 19:26 ` [PATCH 10/12] setterm: use string constant rather than #define Sami Kerola
2014-05-12 12:07   ` Karel Zak
2014-05-11 19:26 ` [PATCH 11/12] setterm: convert various constant number definitions to enums Sami Kerola
2014-05-11 19:26 ` [PATCH 12/12] setterm: convert remaining magic values to symbolic references Sami Kerola
2014-05-12 12:10   ` Karel Zak
2014-05-12 14:53     ` Sami Kerola
2014-05-12  7:05 ` [PATCH 01/12] tests: check /proc availability, and go-around if it is incomplete Bernhard Voelker
2014-05-12  9:13   ` Sami Kerola
2014-05-12 11:06   ` Karel Zak
2014-05-12 12:01 ` Karel Zak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox