All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/34] pull: make printing quicker, and clang analysis
@ 2013-07-07 19:54 Sami Kerola
  2013-07-07 19:54 ` [PATCH 01/34] sfdisk: make unhiding as complete as possible Sami Kerola
                   ` (33 more replies)
  0 siblings, 34 replies; 41+ messages in thread
From: Sami Kerola @ 2013-07-07 19:54 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Hello all,

I quess the theme in this pull request is performance.  More than half of
the patches will make commands to do stuff quicker, either by printing
with better functions or stopping to do things that are unnecessary.  If
I did not misread my rather unscientific speed up measurements impact to
hexdump(1) and more(1) was greatest.


The following changes since commit 81499ab24e15532a8252c1e527d3301d9309c31e:

  findmnt: avoid unused parameter warning (2013-07-03 12:42:06 +0200)

are available in the git repository at:

  git://github.com/kerolasa/lelux-utiliteetit.git 2013wk26

for you to fetch changes up to 7933fd2a938d148f08dfff6652834493f1e9f087:

  more: use variable lenght printf field width to print blanks (2013-07-06 02:25:18 +0100)

----------------------------------------------------------------
Sami Kerola (34):
      sfdisk: make unhiding as complete as possible
      docs: add missing options to sfdisk manual
      include: copy unlocked-io.h from gnulib
      hexdump: use unlocked io, and avoid use of printf()
      text-utils: use unlocked io
      misc-utils: use unlocked io
      scriptreplay: use unlocked io
      dmesg: use unlocked io, and avoid use of printf()
      utmpdump: use unlocked io, and avoid use of printf()
      dmesg: inform user --show-delta and iso8601 time format does not mix
      lib/loopdev: assigned value is never read [clang-analyzer]
      lib/mbsalign: initializations values are never read [clang-analyzer]
      libmount: fix memory leak [clang-analyzer]
      ipcs: assigned values are never read [clang-analyzer]
      lscpu: fix memory leak [clang-analyzer]
      more: assigned value is never read [clang-analyzer]
      utmpdump: assigned values are never read [clang-analyzer]
      mkfs.cramfs: argument to free() is a constant address [clang-analyzer]
      eject: assigned value is never read [clang-analyzer]
      chfn: assigned value is never read [clang-analyzer]
      mesg: assigned value is never read [clang-analyzer]
      rev: assigned value is never read [clang-analyzer]
      column: assigned value is never read [clang-analyzer]
      hwclock: assigned value is never read [clang-analyzer]
      dmesg: assigned value is never read [clang-analyzer]
      login: assigned value is never read [clang-analyzer]
      sfdisk: assigned value is never read [clang-analyzer]
      sulogin: fix memory leak [clang-analyzer]
      agetty: fix memory leak [clang-analyzer]
      dmesg: add missing initializer [clang-analyzer]
      ul: use correct types
      ul: use string printing function
      column: dereference of null pointer [clang-analyzer]
      more: use variable lenght printf field width to print blanks

 configure.ac                   |  13 ++++
 disk-utils/mkfs.cramfs.c       |   1 -
 fdisks/sfdisk.8                |  26 ++++++--
 fdisks/sfdisk.c                |   5 +-
 include/Makemodule.am          |   1 +
 include/unlocked-io.h          | 136 +++++++++++++++++++++++++++++++++++++++++
 lib/loopdev.c                  |   1 -
 lib/mbsalign.c                 |   4 +-
 libmount/src/utils.c           |   1 +
 login-utils/chfn.c             |   1 -
 login-utils/login.c            |   1 -
 login-utils/sulogin-consoles.c |   8 ++-
 login-utils/utmpdump.c         |  13 ++--
 misc-utils/cal.c               |   1 +
 misc-utils/findfs.c            |   1 +
 misc-utils/findmnt.c           |   1 +
 misc-utils/getopt.c            |   1 +
 misc-utils/look.c              |   1 +
 misc-utils/lsblk.c             |   1 +
 misc-utils/lslocks.c           |   1 +
 misc-utils/mcookie.c           |   1 +
 misc-utils/namei.c             |   1 +
 misc-utils/uuidd.c             |   2 +-
 misc-utils/uuidgen.c           |   1 +
 misc-utils/whereis.c           |   1 +
 sys-utils/dmesg.c              |  16 +++--
 sys-utils/eject.c              |   2 +-
 sys-utils/hwclock.c            |   1 -
 sys-utils/ipcs.c               |   3 -
 sys-utils/lscpu-dmi.c          |   4 +-
 term-utils/agetty.c            |   4 +-
 term-utils/mesg.c              |   1 -
 term-utils/scriptreplay.c      |   3 +-
 text-utils/col.c               |   1 +
 text-utils/colcrt.c            |   1 +
 text-utils/colrm.c             |   1 +
 text-utils/column.c            |   4 +-
 text-utils/display.c           |  11 ++--
 text-utils/hexsyntax.c         |   1 +
 text-utils/more.c              |   6 +-
 text-utils/pg.c                |   1 +
 text-utils/rev.c               |   3 +-
 text-utils/tailf.c             |   1 +
 text-utils/ul.c                |  13 ++--
 44 files changed, 251 insertions(+), 50 deletions(-)
 create mode 100644 include/unlocked-io.h



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

* [PATCH 01/34] sfdisk: make unhiding as complete as possible
  2013-07-07 19:54 [PATCH 00/34] pull: make printing quicker, and clang analysis Sami Kerola
@ 2013-07-07 19:54 ` Sami Kerola
  2013-07-07 19:54 ` [PATCH 02/34] docs: add missing options to sfdisk manual Sami Kerola
                   ` (32 subsequent siblings)
  33 siblings, 0 replies; 41+ messages in thread
From: Sami Kerola @ 2013-07-07 19:54 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

It is unlikely anyone will ever need this, but I like idea commands being
complete.  The partition id's that can be unhide after this change are;

Hidden HPFS/NTFS
Hidden W95 FAT32
Hidden W95 FAT32 (LBA)
Hidden W95 FAT16 (LBA)

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 fdisks/sfdisk.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fdisks/sfdisk.c b/fdisks/sfdisk.c
index 6efef47..6b757a7 100644
--- a/fdisks/sfdisk.c
+++ b/fdisks/sfdisk.c
@@ -2992,7 +2992,8 @@ set_unhidden(struct disk_desc *z, char *pnam) {
 
     pno = asc_to_index(pnam, z);
     id = z->partitions[pno].p.sys_type;
-    if (id == 0x11 || id == 0x14 || id == 0x16 || id == 0x17)
+    if (id == 0x11 || id == 0x14 || id == 0x16 || id == 0x17 ||
+	id == 0x17 || id == 0x1b || id == 0x1c || id == 0x1e)
 	id -= 0x10;
     else
 	errx(EXIT_FAILURE, _("partition %s has id %x and is not hidden"), pnam, id);
-- 
1.8.3.2


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

* [PATCH 02/34] docs: add missing options to sfdisk manual
  2013-07-07 19:54 [PATCH 00/34] pull: make printing quicker, and clang analysis Sami Kerola
  2013-07-07 19:54 ` [PATCH 01/34] sfdisk: make unhiding as complete as possible Sami Kerola
@ 2013-07-07 19:54 ` Sami Kerola
  2013-07-07 19:54 ` [PATCH 03/34] include: copy unlocked-io.h from gnulib Sami Kerola
                   ` (31 subsequent siblings)
  33 siblings, 0 replies; 41+ messages in thread
From: Sami Kerola @ 2013-07-07 19:54 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

And improve what is said about four of the dangerous options.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 fdisks/sfdisk.8 | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/fdisks/sfdisk.8 b/fdisks/sfdisk.8
index 2b166fa..e42c5dd 100644
--- a/fdisks/sfdisk.8
+++ b/fdisks/sfdisk.8
@@ -326,6 +326,19 @@ DOS and Linux should interpret the partition table in the same way.
 Of course one can only know where cylinder boundaries are when
 one knows what geometry DOS will use for this disk.)
 .TP
+.BR \-U ", " "\-\-unhide " \fIdevice\fR
+Make various Microsoft partition types unhidden.  For full list see types
+output.
+.IP
+.nf
+.if t .ft CW
+    % sfdisk --list-types | grep Hidden
+.fi
+.IP
+Notice that the
+.B Hidden NTFS WinRE
+(Windows Recovery Environment) does not have non-hidden equivalent.
+.TP
 .BR \-\-IBM ", " \-\-leave\-last
 Certain IBM diagnostic programs assume that they can use the
 last cylinder on a disk for disk-testing purposes.  If you think
@@ -353,16 +366,18 @@ if it is.  This option suppresses the test.  (On the other hand, the \fB\-f\fR
 option would force \fBsfdisk\fR to continue even when this test fails.)
 .TP
 .B \-\-in\-order
-Caution, see warning section.  To be documented.
+Partitions are in order.  See also warning section.
 .TP
 .B \-\-not\-in\-order
-Caution, see warning section.  To be documented.
+Partitions are not in order.  See also warning section.
 .TP
 .B \-\-inside\-outer
-Caution, see warning section.  Chaining order.
+All logical partitions are inside outermost extended.  See also warning
+section and chaining.
 .TP
 .B \-\-not\-inside\-outer
-Caution, see warning section.  Chaining order.
+Some, or none, of the logical partitions are not inside outermost
+extended.  See also warning section and chaining.
 .TP
 .B \-\-nested
 Caution, see warning section.  Every partition is contained in the
@@ -392,6 +407,9 @@ After destroying your filesystems with an unfortunate
 .B sfdisk
 command, you would have been able to restore the old situation
 if only you had preserved it using the \fB\-O\fR flag.
+.TP
+.BR \-1 ", " \-\-one-only
+Reserved option that does nothing currently.
 
 .SH THEORY
 Block 0 of a disk (the Master Boot Record) contains among
-- 
1.8.3.2


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

* [PATCH 03/34] include: copy unlocked-io.h from gnulib
  2013-07-07 19:54 [PATCH 00/34] pull: make printing quicker, and clang analysis Sami Kerola
  2013-07-07 19:54 ` [PATCH 01/34] sfdisk: make unhiding as complete as possible Sami Kerola
  2013-07-07 19:54 ` [PATCH 02/34] docs: add missing options to sfdisk manual Sami Kerola
@ 2013-07-07 19:54 ` Sami Kerola
  2013-07-08 20:21   ` Kay Sievers
  2013-07-07 19:54 ` [PATCH 04/34] hexdump: use unlocked io, and avoid use of printf() Sami Kerola
                   ` (30 subsequent siblings)
  33 siblings, 1 reply; 41+ messages in thread
From: Sami Kerola @ 2013-07-07 19:54 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

At the moment util-linux command are not threading, which means they can
safely use thread-unsafe IO system calls which should make printing
quicker.

References: http://marc.info/?l=util-linux-ng&m=137266928927642&w=3
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 configure.ac          |  13 +++++
 include/Makemodule.am |   1 +
 include/unlocked-io.h | 136 ++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 150 insertions(+)
 create mode 100644 include/unlocked-io.h

diff --git a/configure.ac b/configure.ac
index 398aaf0..4cb87f9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -308,10 +308,21 @@ AC_CHECK_FUNCS([ \
 	__fpending \
 	secure_getenv \
 	__secure_getenv \
+	clearerr_unlocked \
 	err \
 	errx \
+	feof_unlocked \
+	ferror_unlocked \
+	fflush_unlocked \
+	fgets_unlocked \
+	fputc_unlocked \
+	fputs_unlocked \
+	fread_unlocked \
 	fsync \
 	futimens \
+	fwrite_unlocked \
+	getc_unlocked \
+	getchar_unlocked \
 	getdomainname \
 	getdtablesize \
 	getexecname \
@@ -327,6 +338,8 @@ AC_CHECK_FUNCS([ \
 	personality \
 	posix_fadvise \
 	prctl \
+	putc_unlocked \
+	putchar_unlocked \
 	rpmatch \
 	scandirat \
 	setresgid \
diff --git a/include/Makemodule.am b/include/Makemodule.am
index 7ba4593..6d0fd8a 100644
--- a/include/Makemodule.am
+++ b/include/Makemodule.am
@@ -42,6 +42,7 @@ dist_noinst_HEADERS += \
 	include/timer.h \
 	include/tt.h \
 	include/ttyutils.h \
+	include/unlocked-io.h \
 	include/wholedisk.h \
 	include/widechar.h \
 	include/xalloc.h \
diff --git a/include/unlocked-io.h b/include/unlocked-io.h
new file mode 100644
index 0000000..90bc849
--- /dev/null
+++ b/include/unlocked-io.h
@@ -0,0 +1,136 @@
+/* Prefer faster, non-thread-safe stdio functions if available.
+
+   Copyright (C) 2001-2004, 2009-2013 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Jim Meyering.  */
+
+#ifndef UNLOCKED_IO_H
+# define UNLOCKED_IO_H 1
+
+/* These are wrappers for functions/macros from the GNU C library, and
+   from other C libraries supporting POSIX's optional thread-safe functions.
+
+   The standard I/O functions are thread-safe.  These *_unlocked ones are
+   more efficient but not thread-safe.  That they're not thread-safe is
+   fine since all of the applications in this package are single threaded.
+
+   Also, some code that is shared with the GNU C library may invoke
+   the *_unlocked functions directly.  On hosts that lack those
+   functions, invoke the non-thread-safe versions instead.  */
+
+# include <stdio.h>
+
+# if HAVE_CLEARERR_UNLOCKED
+#  undef clearerr
+#  define clearerr(x) clearerr_unlocked (x)
+# else
+#  define clearerr_unlocked(x) clearerr (x)
+# endif
+
+# if HAVE_FEOF_UNLOCKED
+#  undef feof
+#  define feof(x) feof_unlocked (x)
+# else
+#  define feof_unlocked(x) feof (x)
+# endif
+
+# if HAVE_FERROR_UNLOCKED
+#  undef ferror
+#  define ferror(x) ferror_unlocked (x)
+# else
+#  define ferror_unlocked(x) ferror (x)
+# endif
+
+# if HAVE_FFLUSH_UNLOCKED
+#  undef fflush
+#  define fflush(x) fflush_unlocked (x)
+# else
+#  define fflush_unlocked(x) fflush (x)
+# endif
+
+# if HAVE_FGETS_UNLOCKED
+#  undef fgets
+#  define fgets(x,y,z) fgets_unlocked (x,y,z)
+# else
+#  define fgets_unlocked(x,y,z) fgets (x,y,z)
+# endif
+
+# if HAVE_FPUTC_UNLOCKED
+#  undef fputc
+#  define fputc(x,y) fputc_unlocked (x,y)
+# else
+#  define fputc_unlocked(x,y) fputc (x,y)
+# endif
+
+# if HAVE_FPUTS_UNLOCKED
+#  undef fputs
+#  define fputs(x,y) fputs_unlocked (x,y)
+# else
+#  define fputs_unlocked(x,y) fputs (x,y)
+# endif
+
+# if HAVE_FREAD_UNLOCKED
+#  undef fread
+#  define fread(w,x,y,z) fread_unlocked (w,x,y,z)
+# else
+#  define fread_unlocked(w,x,y,z) fread (w,x,y,z)
+# endif
+
+# if HAVE_FWRITE_UNLOCKED
+#  undef fwrite
+#  define fwrite(w,x,y,z) fwrite_unlocked (w,x,y,z)
+# else
+#  define fwrite_unlocked(w,x,y,z) fwrite (w,x,y,z)
+# endif
+
+# if HAVE_GETC_UNLOCKED
+#  undef getc
+#  define getc(x) getc_unlocked (x)
+# else
+#  define getc_unlocked(x) getc (x)
+# endif
+
+# if HAVE_GETCHAR_UNLOCKED
+#  undef getchar
+#  define getchar() getchar_unlocked ()
+# else
+#  define getchar_unlocked() getchar ()
+# endif
+
+# if HAVE_PUTC_UNLOCKED
+#  undef putc
+#  define putc(x,y) putc_unlocked (x,y)
+# else
+#  define putc_unlocked(x,y) putc (x,y)
+# endif
+
+# if HAVE_PUTCHAR_UNLOCKED
+#  undef putchar
+#  define putchar(x) putchar_unlocked (x)
+# else
+#  define putchar_unlocked(x) putchar (x)
+# endif
+
+# undef flockfile
+# define flockfile(x) ((void) 0)
+
+# undef ftrylockfile
+# define ftrylockfile(x) 0
+
+# undef funlockfile
+# define funlockfile(x) ((void) 0)
+
+#endif /* UNLOCKED_IO_H */
-- 
1.8.3.2


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

* [PATCH 04/34] hexdump: use unlocked io, and avoid use of printf()
  2013-07-07 19:54 [PATCH 00/34] pull: make printing quicker, and clang analysis Sami Kerola
                   ` (2 preceding siblings ...)
  2013-07-07 19:54 ` [PATCH 03/34] include: copy unlocked-io.h from gnulib Sami Kerola
@ 2013-07-07 19:54 ` Sami Kerola
  2013-07-07 19:54 ` [PATCH 05/34] text-utils: use unlocked io Sami Kerola
                   ` (29 subsequent siblings)
  33 siblings, 0 replies; 41+ messages in thread
From: Sami Kerola @ 2013-07-07 19:54 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

This makes common cases about 35-50% quicker.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 text-utils/display.c   | 11 ++++++-----
 text-utils/hexsyntax.c |  1 +
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/text-utils/display.c b/text-utils/display.c
index 41ddd8d..21a59c2 100644
--- a/text-utils/display.c
+++ b/text-utils/display.c
@@ -39,6 +39,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include "unlocked-io.h"
 #include "hexdump.h"
 #include "xalloc.h"
 #include "c.h"
@@ -110,13 +111,13 @@ print(PR *pr, unsigned char *bp) {
 		break;
 	    }
 	case F_P:
-		(void)printf(pr->fmt, isprint(*bp) ? *bp : '.');
+		putchar(isprint(*bp) ? *bp : '.');
 		break;
 	case F_STR:
 		(void)printf(pr->fmt, (char *)bp);
 		break;
 	case F_TEXT:
-		(void)printf("%s", pr->fmt);
+		fputs(pr->fmt, stdout);
 		break;
 	case F_U:
 		conv_u(pr, bp);
@@ -213,7 +214,7 @@ void display(void)
 				(void)printf(pr->fmt, (int64_t)eaddress);
 				break;
 			case F_TEXT:
-				(void)printf("%s", pr->fmt);
+				fputs(pr->fmt, stdout);
 				break;
 			}
 	}
@@ -250,7 +251,7 @@ get(void)
 			if (!need && vflag != ALL &&
 			    !memcmp(curp, savp, nread)) {
 				if (vflag != DUP)
-					(void)printf("*\n");
+					fputs("*\n", stdout);
 				return(NULL);
 			}
 			if (need > 0)
@@ -281,7 +282,7 @@ get(void)
 				return(curp);
 			}
 			if (vflag == WAIT)
-				(void)printf("*\n");
+				fputs("*\n", stdout);
 			vflag = DUP;
 			address += blocksize;
 			need = blocksize;
diff --git a/text-utils/hexsyntax.c b/text-utils/hexsyntax.c
index 2910ca5..a97ce11 100644
--- a/text-utils/hexsyntax.c
+++ b/text-utils/hexsyntax.c
@@ -43,6 +43,7 @@
 #include <err.h>
 #include <limits.h>
 #include <getopt.h>
+#include "unlocked-io.h"
 #include "hexdump.h"
 #include "nls.h"
 #include "strutils.h"
-- 
1.8.3.2


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

* [PATCH 05/34] text-utils: use unlocked io
  2013-07-07 19:54 [PATCH 00/34] pull: make printing quicker, and clang analysis Sami Kerola
                   ` (3 preceding siblings ...)
  2013-07-07 19:54 ` [PATCH 04/34] hexdump: use unlocked io, and avoid use of printf() Sami Kerola
@ 2013-07-07 19:54 ` Sami Kerola
  2013-07-07 19:54 ` [PATCH 06/34] misc-utils: " Sami Kerola
                   ` (28 subsequent siblings)
  33 siblings, 0 replies; 41+ messages in thread
From: Sami Kerola @ 2013-07-07 19:54 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 text-utils/col.c    | 1 +
 text-utils/colcrt.c | 1 +
 text-utils/colrm.c  | 1 +
 text-utils/column.c | 1 +
 text-utils/more.c   | 1 +
 text-utils/pg.c     | 1 +
 text-utils/rev.c    | 1 +
 text-utils/tailf.c  | 1 +
 text-utils/ul.c     | 1 +
 9 files changed, 9 insertions(+)

diff --git a/text-utils/col.c b/text-utils/col.c
index 9aa6a41..a18d45f 100644
--- a/text-utils/col.c
+++ b/text-utils/col.c
@@ -52,6 +52,7 @@
 #include <unistd.h>
 #include <getopt.h>
 
+#include "unlocked-io.h"
 #include "nls.h"
 #include "xalloc.h"
 #include "widechar.h"
diff --git a/text-utils/colcrt.c b/text-utils/colcrt.c
index 6c7f636..72115fb 100644
--- a/text-utils/colcrt.c
+++ b/text-utils/colcrt.c
@@ -45,6 +45,7 @@
 #include <getopt.h>
 #include "nls.h"
 
+#include "unlocked-io.h"
 #include "widechar.h"
 #include "c.h"
 #include "closestream.h"
diff --git a/text-utils/colrm.c b/text-utils/colrm.c
index 454085e..5bdc7f5 100644
--- a/text-utils/colrm.c
+++ b/text-utils/colrm.c
@@ -48,6 +48,7 @@
 #include "strutils.h"
 #include "c.h"
 #include "closestream.h"
+#include "unlocked-io.h"
 
 /*
 COLRM removes unwanted columns from a file
diff --git a/text-utils/column.c b/text-utils/column.c
index e29ea47..ee9fdd7 100644
--- a/text-utils/column.c
+++ b/text-utils/column.c
@@ -49,6 +49,7 @@
 #include <errno.h>
 #include <getopt.h>
 
+#include "unlocked-io.h"
 #include "nls.h"
 #include "widechar.h"
 #include "c.h"
diff --git a/text-utils/more.c b/text-utils/more.c
index 66de2bf..bdc5bf9 100644
--- a/text-utils/more.c
+++ b/text-utils/more.c
@@ -65,6 +65,7 @@
 #include "xalloc.h"
 #include "widechar.h"
 #include "closestream.h"
+#include "unlocked-io.h"
 
 #include <regex.h>
 
diff --git a/text-utils/pg.c b/text-utils/pg.c
index 7b61e6b..30a47c8 100644
--- a/text-utils/pg.c
+++ b/text-utils/pg.c
@@ -65,6 +65,7 @@
 #include "all-io.h"
 #include "closestream.h"
 #include "strutils.h"
+#include "unlocked-io.h"
 
 #define	READBUF		LINE_MAX	/* size of input buffer */
 #define CMDBUF		255		/* size of command buffer */
diff --git a/text-utils/rev.c b/text-utils/rev.c
index 1c44036..13249de 100644
--- a/text-utils/rev.c
+++ b/text-utils/rev.c
@@ -63,6 +63,7 @@
 #include "widechar.h"
 #include "c.h"
 #include "closestream.h"
+#include "unlocked-io.h"
 
 wchar_t *buf;
 
diff --git a/text-utils/tailf.c b/text-utils/tailf.c
index 2f611a4..c673bbf 100644
--- a/text-utils/tailf.c
+++ b/text-utils/tailf.c
@@ -45,6 +45,7 @@
 #include "strutils.h"
 #include "c.h"
 #include "closestream.h"
+#include "unlocked-io.h"
 
 #define DEFAULT_LINES  10
 
diff --git a/text-utils/ul.c b/text-utils/ul.c
index 7b50ede..c2c19f6 100644
--- a/text-utils/ul.c
+++ b/text-utils/ul.c
@@ -55,6 +55,7 @@
 #include "widechar.h"
 #include "c.h"
 #include "closestream.h"
+#include "unlocked-io.h"
 
 #ifdef HAVE_WIDECHAR
 /* Output an ASCII character as a wide character */
-- 
1.8.3.2


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

* [PATCH 06/34] misc-utils: use unlocked io
  2013-07-07 19:54 [PATCH 00/34] pull: make printing quicker, and clang analysis Sami Kerola
                   ` (4 preceding siblings ...)
  2013-07-07 19:54 ` [PATCH 05/34] text-utils: use unlocked io Sami Kerola
@ 2013-07-07 19:54 ` Sami Kerola
  2013-07-07 19:54 ` [PATCH 07/34] scriptreplay: " Sami Kerola
                   ` (27 subsequent siblings)
  33 siblings, 0 replies; 41+ messages in thread
From: Sami Kerola @ 2013-07-07 19:54 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 misc-utils/cal.c     | 1 +
 misc-utils/findfs.c  | 1 +
 misc-utils/findmnt.c | 1 +
 misc-utils/getopt.c  | 1 +
 misc-utils/look.c    | 1 +
 misc-utils/lsblk.c   | 1 +
 misc-utils/lslocks.c | 1 +
 misc-utils/mcookie.c | 1 +
 misc-utils/namei.c   | 1 +
 misc-utils/uuidgen.c | 1 +
 misc-utils/whereis.c | 1 +
 11 files changed, 11 insertions(+)

diff --git a/misc-utils/cal.c b/misc-utils/cal.c
index c4ed1d1..b46af3a 100644
--- a/misc-utils/cal.c
+++ b/misc-utils/cal.c
@@ -72,6 +72,7 @@
 #include "nls.h"
 #include "mbsalign.h"
 #include "strutils.h"
+#include "unlocked-io.h"
 
 #if defined(HAVE_LIBNCURSES) || defined(HAVE_LIBNCURSESW)
 # ifdef HAVE_NCURSES_H
diff --git a/misc-utils/findfs.c b/misc-utils/findfs.c
index bc4a843..e3e6e68 100644
--- a/misc-utils/findfs.c
+++ b/misc-utils/findfs.c
@@ -14,6 +14,7 @@
 #include "nls.h"
 #include "closestream.h"
 #include "c.h"
+#include "unlocked-io.h"
 
 static void __attribute__((__noreturn__)) usage(int rc)
 {
diff --git a/misc-utils/findmnt.c b/misc-utils/findmnt.c
index 8ccceda..1febde0 100644
--- a/misc-utils/findmnt.c
+++ b/misc-utils/findmnt.c
@@ -46,6 +46,7 @@
 #include "xalloc.h"
 #include "optutils.h"
 #include "mangle.h"
+#include "unlocked-io.h"
 
 /* flags */
 enum {
diff --git a/misc-utils/getopt.c b/misc-utils/getopt.c
index 7630173..9ef7c79 100644
--- a/misc-utils/getopt.c
+++ b/misc-utils/getopt.c
@@ -60,6 +60,7 @@
 
 #include "closestream.h"
 #include "nls.h"
+#include "unlocked-io.h"
 #include "xalloc.h"
 
 /* NON_OPT is the code that is returned when a non-option is found in '+'
diff --git a/misc-utils/look.c b/misc-utils/look.c
index 502168b..22b1381 100644
--- a/misc-utils/look.c
+++ b/misc-utils/look.c
@@ -61,6 +61,7 @@
 #include "xalloc.h"
 #include "pathnames.h"
 #include "closestream.h"
+#include "unlocked-io.h"
 
 #define	EQUAL		0
 #define	GREATER		1
diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c
index 494bc73..3eaaa40 100644
--- a/misc-utils/lsblk.c
+++ b/misc-utils/lsblk.c
@@ -61,6 +61,7 @@
 #include "closestream.h"
 #include "mangle.h"
 #include "optutils.h"
+#include "unlocked-io.h"
 
 /* column IDs */
 enum {
diff --git a/misc-utils/lslocks.c b/misc-utils/lslocks.c
index de3094a..b30a56c 100644
--- a/misc-utils/lslocks.c
+++ b/misc-utils/lslocks.c
@@ -43,6 +43,7 @@
 #include "strutils.h"
 #include "c.h"
 #include "closestream.h"
+#include "unlocked-io.h"
 
 /* column IDs */
 enum {
diff --git a/misc-utils/mcookie.c b/misc-utils/mcookie.c
index da641a1..a505fd2 100644
--- a/misc-utils/mcookie.c
+++ b/misc-utils/mcookie.c
@@ -22,6 +22,7 @@
 #include "md5.h"
 #include "nls.h"
 #include "closestream.h"
+#include "unlocked-io.h"
 
 #include <fcntl.h>
 #include <getopt.h>
diff --git a/misc-utils/namei.c b/misc-utils/namei.c
index a9c8301..6ce0d6e 100644
--- a/misc-utils/namei.c
+++ b/misc-utils/namei.c
@@ -38,6 +38,7 @@
 #include "widechar.h"
 #include "strutils.h"
 #include "closestream.h"
+#include "unlocked-io.h"
 
 #ifndef MAXSYMLINKS
 #define MAXSYMLINKS 256
diff --git a/misc-utils/uuidgen.c b/misc-utils/uuidgen.c
index 450e26a..2dd829d 100644
--- a/misc-utils/uuidgen.c
+++ b/misc-utils/uuidgen.c
@@ -25,6 +25,7 @@ extern int optind;
 #include "nls.h"
 #include "c.h"
 #include "closestream.h"
+#include "unlocked-io.h"
 
 #define DO_TYPE_TIME	1
 #define DO_TYPE_RANDOM	2
diff --git a/misc-utils/whereis.c b/misc-utils/whereis.c
index ba83b15..8f0fa9e 100644
--- a/misc-utils/whereis.c
+++ b/misc-utils/whereis.c
@@ -54,6 +54,7 @@
 #include "c.h"
 #include "closestream.h"
 #include "canonicalize.h"
+#include "unlocked-io.h"
 
 /*#define DEBUG*/
 
-- 
1.8.3.2


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

* [PATCH 07/34] scriptreplay: use unlocked io
  2013-07-07 19:54 [PATCH 00/34] pull: make printing quicker, and clang analysis Sami Kerola
                   ` (5 preceding siblings ...)
  2013-07-07 19:54 ` [PATCH 06/34] misc-utils: " Sami Kerola
@ 2013-07-07 19:54 ` Sami Kerola
  2013-07-07 19:54 ` [PATCH 09/34] utmpdump: use unlocked io, and avoid use of printf() Sami Kerola
                   ` (26 subsequent siblings)
  33 siblings, 0 replies; 41+ messages in thread
From: Sami Kerola @ 2013-07-07 19:54 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

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

diff --git a/term-utils/scriptreplay.c b/term-utils/scriptreplay.c
index 46468be..a366c35 100644
--- a/term-utils/scriptreplay.c
+++ b/term-utils/scriptreplay.c
@@ -31,6 +31,7 @@
 #include "closestream.h"
 #include "nls.h"
 #include "c.h"
+#include "unlocked-io.h"
 
 #define SCRIPT_MIN_DELAY 0.0001		/* from original sripreplay.pl */
 
@@ -229,6 +230,6 @@ main(int argc, char *argv[])
 
 	fclose(sfile);
 	fclose(tfile);
-	printf("\n");
+	fputs("\n", stdout);
 	exit(EXIT_SUCCESS);
 }
-- 
1.8.3.2


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

* [PATCH 09/34] utmpdump: use unlocked io, and avoid use of printf()
  2013-07-07 19:54 [PATCH 00/34] pull: make printing quicker, and clang analysis Sami Kerola
                   ` (6 preceding siblings ...)
  2013-07-07 19:54 ` [PATCH 07/34] scriptreplay: " Sami Kerola
@ 2013-07-07 19:54 ` Sami Kerola
  2013-07-07 19:54 ` [PATCH 10/34] dmesg: inform user --show-delta and iso8601 time format does not mix Sami Kerola
                   ` (25 subsequent siblings)
  33 siblings, 0 replies; 41+ messages in thread
From: Sami Kerola @ 2013-07-07 19:54 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

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

diff --git a/login-utils/utmpdump.c b/login-utils/utmpdump.c
index af3f7c0..3febeaf 100644
--- a/login-utils/utmpdump.c
+++ b/login-utils/utmpdump.c
@@ -44,6 +44,7 @@
 #include "nls.h"
 #include "xalloc.h"
 #include "closestream.h"
+#include "unlocked-io.h"
 
 static char *timetostr(const time_t time)
 {
@@ -361,10 +362,14 @@ int main(int argc, char **argv)
 	}
 
 	if (reverse) {
-		fprintf(stderr, _("Utmp undump of %s\n"), filename);
+		fputs(_("Utmp undump of"), stderr);
+		fputs(filename, stderr);
+		fputs("\n", stderr);
 		undump(in, out);
 	} else {
-		fprintf(stderr, _("Utmp dump of %s\n"), filename);
+		fputs(_("Utmp dump of"), stderr);
+		fputs(filename, stderr);
+		fputs("\n", stderr);
 		in = dump(in, filename, follow, out);
 	}
 
-- 
1.8.3.2


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

* [PATCH 10/34] dmesg: inform user --show-delta and iso8601 time format does not mix
  2013-07-07 19:54 [PATCH 00/34] pull: make printing quicker, and clang analysis Sami Kerola
                   ` (7 preceding siblings ...)
  2013-07-07 19:54 ` [PATCH 09/34] utmpdump: use unlocked io, and avoid use of printf() Sami Kerola
@ 2013-07-07 19:54 ` Sami Kerola
  2013-07-07 19:54 ` [PATCH 11/34] lib/loopdev: assigned value is never read [clang-analyzer] Sami Kerola
                   ` (24 subsequent siblings)
  33 siblings, 0 replies; 41+ messages in thread
From: Sami Kerola @ 2013-07-07 19:54 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

References: http://marc.info/?l=util-linux-ng&m=137267606929951&w=2
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 sys-utils/dmesg.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c
index 881e3ac..64b1c09 100644
--- a/sys-utils/dmesg.c
+++ b/sys-utils/dmesg.c
@@ -1370,6 +1370,9 @@ int main(int argc, char *argv[])
 		case DMESG_TIMEFTM_TIME:
 			ctl.time_fmt = DMESG_TIMEFTM_TIME_DELTA;
 			break;
+		case DMESG_TIMEFTM_ISO8601:
+			warnx(_("--show-delta is ignored when used together with iso8601 time format"));
+			break;
 		default:
 			ctl.time_fmt = DMESG_TIMEFTM_DELTA;
 		}
-- 
1.8.3.2


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

* [PATCH 11/34] lib/loopdev: assigned value is never read [clang-analyzer]
  2013-07-07 19:54 [PATCH 00/34] pull: make printing quicker, and clang analysis Sami Kerola
                   ` (8 preceding siblings ...)
  2013-07-07 19:54 ` [PATCH 10/34] dmesg: inform user --show-delta and iso8601 time format does not mix Sami Kerola
@ 2013-07-07 19:54 ` Sami Kerola
  2013-07-07 19:54 ` [PATCH 12/34] lib/mbsalign: initializations values are " Sami Kerola
                   ` (23 subsequent siblings)
  33 siblings, 0 replies; 41+ messages in thread
From: Sami Kerola @ 2013-07-07 19:54 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 lib/loopdev.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/lib/loopdev.c b/lib/loopdev.c
index 3b65b5d..001a9ad 100644
--- a/lib/loopdev.c
+++ b/lib/loopdev.c
@@ -1234,7 +1234,6 @@ int loopcxt_setup_device(struct loopdev_cxt *lc)
 		goto err;
 
 	close(file_fd);
-	file_fd = -1;
 
 	memset(&lc->info, 0, sizeof(lc->info));
 	lc->has_info = 0;
-- 
1.8.3.2


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

* [PATCH 12/34] lib/mbsalign: initializations values are never read [clang-analyzer]
  2013-07-07 19:54 [PATCH 00/34] pull: make printing quicker, and clang analysis Sami Kerola
                   ` (9 preceding siblings ...)
  2013-07-07 19:54 ` [PATCH 11/34] lib/loopdev: assigned value is never read [clang-analyzer] Sami Kerola
@ 2013-07-07 19:54 ` Sami Kerola
  2013-07-07 19:54 ` [PATCH 13/34] libmount: fix memory leak [clang-analyzer] Sami Kerola
                   ` (22 subsequent siblings)
  33 siblings, 0 replies; 41+ messages in thread
From: Sami Kerola @ 2013-07-07 19:54 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

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

diff --git a/lib/mbsalign.c b/lib/mbsalign.c
index e420fea..89ef032 100644
--- a/lib/mbsalign.c
+++ b/lib/mbsalign.c
@@ -254,8 +254,8 @@ mbsalign_unibyte:
   if (dest_size != 0)
     {
       char *dest_end = dest + dest_size - 1;
-      size_t start_spaces = n_spaces / 2 + n_spaces % 2;
-      size_t end_spaces = n_spaces / 2;
+      size_t start_spaces;
+      size_t end_spaces;
 
       switch (align)
         {
-- 
1.8.3.2


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

* [PATCH 13/34] libmount: fix memory leak [clang-analyzer]
  2013-07-07 19:54 [PATCH 00/34] pull: make printing quicker, and clang analysis Sami Kerola
                   ` (10 preceding siblings ...)
  2013-07-07 19:54 ` [PATCH 12/34] lib/mbsalign: initializations values are " Sami Kerola
@ 2013-07-07 19:54 ` Sami Kerola
  2013-07-08  8:02   ` Karel Zak
  2013-07-07 19:54 ` [PATCH 14/34] ipcs: assigned values are never read [clang-analyzer] Sami Kerola
                   ` (21 subsequent siblings)
  33 siblings, 1 reply; 41+ messages in thread
From: Sami Kerola @ 2013-07-07 19:54 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 libmount/src/utils.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libmount/src/utils.c b/libmount/src/utils.c
index 1655764..7714b50 100644
--- a/libmount/src/utils.c
+++ b/libmount/src/utils.c
@@ -198,6 +198,7 @@ int mnt_chdir_to_parent(const char *target, char **filename)
 		else
 			memcpy(*filename, last, strlen(last) + 1);
 	}
+	free(buf);
 	return 0;
 err:
 	free(buf);
-- 
1.8.3.2


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

* [PATCH 14/34] ipcs: assigned values are never read [clang-analyzer]
  2013-07-07 19:54 [PATCH 00/34] pull: make printing quicker, and clang analysis Sami Kerola
                   ` (11 preceding siblings ...)
  2013-07-07 19:54 ` [PATCH 13/34] libmount: fix memory leak [clang-analyzer] Sami Kerola
@ 2013-07-07 19:54 ` Sami Kerola
  2013-07-07 19:54 ` [PATCH 15/34] lscpu: fix memory leak [clang-analyzer] Sami Kerola
                   ` (20 subsequent siblings)
  33 siblings, 0 replies; 41+ messages in thread
From: Sami Kerola @ 2013-07-07 19:54 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 sys-utils/ipcs.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/sys-utils/ipcs.c b/sys-utils/ipcs.c
index 14f5f0b..16e5206 100644
--- a/sys-utils/ipcs.c
+++ b/sys-utils/ipcs.c
@@ -278,7 +278,6 @@ static void do_shm (char format, int unit)
 	 */
 	if (ipc_shm_get_info(-1, &shmds) < 1)
 		return;
-	shmdsp = shmds;
 
 	for (shmdsp = shmds; shmdsp->next != NULL; shmdsp = shmdsp->next) {
 		if (format == CREATOR)  {
@@ -396,7 +395,6 @@ static void do_sem (char format)
 	 */
 	if (ipc_sem_get_info(-1, &semds) < 1)
 		return;
-	semdsp = semds;
 
 	for (semdsp = semds; semdsp->next != NULL; semdsp = semdsp->next) {
 		if (format == CREATOR)  {
@@ -501,7 +499,6 @@ static void do_msg (char format, int unit)
 	 */
 	if (ipc_msg_get_info(-1, &msgds) < 1)
 		return;
-	msgdsp = msgds;
 
 	for (msgdsp = msgds; msgdsp->next != NULL; msgdsp = msgdsp->next) {
 		if (format == CREATOR) {
-- 
1.8.3.2


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

* [PATCH 15/34] lscpu: fix memory leak [clang-analyzer]
  2013-07-07 19:54 [PATCH 00/34] pull: make printing quicker, and clang analysis Sami Kerola
                   ` (12 preceding siblings ...)
  2013-07-07 19:54 ` [PATCH 14/34] ipcs: assigned values are never read [clang-analyzer] Sami Kerola
@ 2013-07-07 19:54 ` Sami Kerola
  2013-07-07 19:54 ` [PATCH 16/34] more: assigned value is never read [clang-analyzer] Sami Kerola
                   ` (19 subsequent siblings)
  33 siblings, 0 replies; 41+ messages in thread
From: Sami Kerola @ 2013-07-07 19:54 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 sys-utils/lscpu-dmi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sys-utils/lscpu-dmi.c b/sys-utils/lscpu-dmi.c
index 21e024b..8f02779 100644
--- a/sys-utils/lscpu-dmi.c
+++ b/sys-utils/lscpu-dmi.c
@@ -130,8 +130,10 @@ static int hypervisor_from_dmi_table(uint32_t base, uint16_t len,
 		 * is invalid, but we cannot reliably locate the next entry.
 		 * Better stop at this point.
 		 */
-		if (h.length < 4)
+		if (h.length < 4) {
+			free(data);
 			return HYPER_NONE;
+		}
 
 		/* look for the next handle */
 		next = data + h.length;
-- 
1.8.3.2


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

* [PATCH 16/34] more: assigned value is never read [clang-analyzer]
  2013-07-07 19:54 [PATCH 00/34] pull: make printing quicker, and clang analysis Sami Kerola
                   ` (13 preceding siblings ...)
  2013-07-07 19:54 ` [PATCH 15/34] lscpu: fix memory leak [clang-analyzer] Sami Kerola
@ 2013-07-07 19:54 ` Sami Kerola
  2013-07-07 19:54 ` [PATCH 17/34] utmpdump: assigned values are " Sami Kerola
                   ` (18 subsequent siblings)
  33 siblings, 0 replies; 41+ messages in thread
From: Sami Kerola @ 2013-07-07 19:54 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 text-utils/more.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/text-utils/more.c b/text-utils/more.c
index bdc5bf9..62de6ad 100644
--- a/text-utils/more.c
+++ b/text-utils/more.c
@@ -1581,7 +1581,7 @@ void search(char buf[], FILE *file, register int n)
 	long startline = Ftell(file);
 	register long line1 = startline;
 	register long line2 = startline;
-	register long line3 = startline;
+	register long line3;
 	register int lncount;
 	int saveln, rc;
 	regex_t re;
-- 
1.8.3.2


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

* [PATCH 17/34] utmpdump: assigned values are never read [clang-analyzer]
  2013-07-07 19:54 [PATCH 00/34] pull: make printing quicker, and clang analysis Sami Kerola
                   ` (14 preceding siblings ...)
  2013-07-07 19:54 ` [PATCH 16/34] more: assigned value is never read [clang-analyzer] Sami Kerola
@ 2013-07-07 19:54 ` Sami Kerola
  2013-07-07 19:54 ` [PATCH 18/34] mkfs.cramfs: argument to free() is a constant address [clang-analyzer] Sami Kerola
                   ` (17 subsequent siblings)
  33 siblings, 0 replies; 41+ messages in thread
From: Sami Kerola @ 2013-07-07 19:54 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

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

diff --git a/login-utils/utmpdump.c b/login-utils/utmpdump.c
index 3febeaf..8b6f17d 100644
--- a/login-utils/utmpdump.c
+++ b/login-utils/utmpdump.c
@@ -252,7 +252,7 @@ static void undump(FILE *in, FILE *out)
 	char s_addr[16], s_time[29], *linestart, *line;
 	int count = 0;
 
-	line = linestart = xmalloc(1024 * sizeof(*linestart));
+	linestart = xmalloc(1024 * sizeof(*linestart));
 	s_addr[15] = 0;
 	s_time[28] = 0;
 
@@ -266,7 +266,7 @@ static void undump(FILE *in, FILE *out)
 		line += gettok(line, ut.ut_line, sizeof(ut.ut_line), 1);
 		line += gettok(line, ut.ut_host, sizeof(ut.ut_host), 1);
 		line += gettok(line, s_addr, sizeof(s_addr) - 1, 1);
-		line += gettok(line, s_time, sizeof(s_time) - 1, 0);
+		gettok(line, s_time, sizeof(s_time) - 1, 0);
 
 		ut.ut_addr = inet_addr(s_addr);
 		ut.ut_time = strtotime(s_time);
-- 
1.8.3.2


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

* [PATCH 18/34] mkfs.cramfs: argument to free() is a constant address [clang-analyzer]
  2013-07-07 19:54 [PATCH 00/34] pull: make printing quicker, and clang analysis Sami Kerola
                   ` (15 preceding siblings ...)
  2013-07-07 19:54 ` [PATCH 17/34] utmpdump: assigned values are " Sami Kerola
@ 2013-07-07 19:54 ` Sami Kerola
  2013-07-07 19:54 ` [PATCH 19/34] eject: assigned value is never read [clang-analyzer] Sami Kerola
                   ` (16 subsequent siblings)
  33 siblings, 0 replies; 41+ messages in thread
From: Sami Kerola @ 2013-07-07 19:54 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 disk-utils/mkfs.cramfs.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/disk-utils/mkfs.cramfs.c b/disk-utils/mkfs.cramfs.c
index fdc2cae..ebc8112 100644
--- a/disk-utils/mkfs.cramfs.c
+++ b/disk-utils/mkfs.cramfs.c
@@ -168,7 +168,6 @@ do_mmap(char *path, unsigned int size, unsigned int mode){
 
 	start = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
 	if (-1 == (int) (long) start) {
-		free(start);
 		close(fd);
 		err(MKFS_EX_ERROR, "mmap");
 	}
-- 
1.8.3.2


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

* [PATCH 19/34] eject: assigned value is never read [clang-analyzer]
  2013-07-07 19:54 [PATCH 00/34] pull: make printing quicker, and clang analysis Sami Kerola
                   ` (16 preceding siblings ...)
  2013-07-07 19:54 ` [PATCH 18/34] mkfs.cramfs: argument to free() is a constant address [clang-analyzer] Sami Kerola
@ 2013-07-07 19:54 ` Sami Kerola
  2013-07-07 19:54 ` [PATCH 20/34] chfn: " Sami Kerola
                   ` (15 subsequent siblings)
  33 siblings, 0 replies; 41+ messages in thread
From: Sami Kerola @ 2013-07-07 19:54 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 sys-utils/eject.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys-utils/eject.c b/sys-utils/eject.c
index f98f227..5bcde68 100644
--- a/sys-utils/eject.c
+++ b/sys-utils/eject.c
@@ -636,7 +636,7 @@ static int eject_scsi(int fd)
 		return 0;
 
 	/* force kernel to reread partition table when new disc inserted */
-	status = ioctl(fd, BLKRRPART);
+	ioctl(fd, BLKRRPART);
 	return 1;
 }
 
-- 
1.8.3.2


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

* [PATCH 20/34] chfn: assigned value is never read [clang-analyzer]
  2013-07-07 19:54 [PATCH 00/34] pull: make printing quicker, and clang analysis Sami Kerola
                   ` (17 preceding siblings ...)
  2013-07-07 19:54 ` [PATCH 19/34] eject: assigned value is never read [clang-analyzer] Sami Kerola
@ 2013-07-07 19:54 ` Sami Kerola
  2013-07-07 19:54 ` [PATCH 21/34] mesg: " Sami Kerola
                   ` (14 subsequent siblings)
  33 siblings, 0 replies; 41+ messages in thread
From: Sami Kerola @ 2013-07-07 19:54 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 login-utils/chfn.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/login-utils/chfn.c b/login-utils/chfn.c
index 95e8d9d..5aa491d 100644
--- a/login-utils/chfn.c
+++ b/login-utils/chfn.c
@@ -227,7 +227,6 @@ static int parse_argv(int argc, char *argv[], struct finfo *pinfo)
 			usage(stderr);
 		/* ok, we were given an argument */
 		info_given = true;
-		status = 0;
 
 		/* now store the argument */
 		switch (c) {
-- 
1.8.3.2


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

* [PATCH 21/34] mesg: assigned value is never read [clang-analyzer]
  2013-07-07 19:54 [PATCH 00/34] pull: make printing quicker, and clang analysis Sami Kerola
                   ` (18 preceding siblings ...)
  2013-07-07 19:54 ` [PATCH 20/34] chfn: " Sami Kerola
@ 2013-07-07 19:54 ` Sami Kerola
  2013-07-08  8:23   ` Karel Zak
  2013-07-07 19:54 ` [PATCH 22/34] rev: " Sami Kerola
                   ` (13 subsequent siblings)
  33 siblings, 1 reply; 41+ messages in thread
From: Sami Kerola @ 2013-07-07 19:54 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 term-utils/mesg.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/term-utils/mesg.c b/term-utils/mesg.c
index 430236f..638a8c7 100644
--- a/term-utils/mesg.c
+++ b/term-utils/mesg.c
@@ -115,7 +115,6 @@ int main(int argc, char *argv[])
 			usage(stderr);
 		}
 
-	argc -= optind;
 	argv += optind;
 
 	if ((tty = ttyname(STDERR_FILENO)) == NULL)
-- 
1.8.3.2


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

* [PATCH 22/34] rev: assigned value is never read [clang-analyzer]
  2013-07-07 19:54 [PATCH 00/34] pull: make printing quicker, and clang analysis Sami Kerola
                   ` (19 preceding siblings ...)
  2013-07-07 19:54 ` [PATCH 21/34] mesg: " Sami Kerola
@ 2013-07-07 19:54 ` Sami Kerola
  2013-07-07 19:54 ` [PATCH 23/34] column: " Sami Kerola
                   ` (12 subsequent siblings)
  33 siblings, 0 replies; 41+ messages in thread
From: Sami Kerola @ 2013-07-07 19:54 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 text-utils/rev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/text-utils/rev.c b/text-utils/rev.c
index 13249de..0764466 100644
--- a/text-utils/rev.c
+++ b/text-utils/rev.c
@@ -121,7 +121,6 @@ int main(int argc, char *argv[])
 			usage(stderr);
 		}
 
-	argc -= optind;
 	argv += optind;
 
 	buf = xmalloc(bufsiz * sizeof(wchar_t));
@@ -173,3 +172,4 @@ int main(int argc, char *argv[])
 	return rval;
 }
 
+ 
-- 
1.8.3.2


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

* [PATCH 23/34] column: assigned value is never read [clang-analyzer]
  2013-07-07 19:54 [PATCH 00/34] pull: make printing quicker, and clang analysis Sami Kerola
                   ` (20 preceding siblings ...)
  2013-07-07 19:54 ` [PATCH 22/34] rev: " Sami Kerola
@ 2013-07-07 19:54 ` Sami Kerola
  2013-07-07 19:54 ` [PATCH 24/34] hwclock: " Sami Kerola
                   ` (11 subsequent siblings)
  33 siblings, 0 replies; 41+ messages in thread
From: Sami Kerola @ 2013-07-07 19:54 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 text-utils/column.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/text-utils/column.c b/text-utils/column.c
index ee9fdd7..25a2286 100644
--- a/text-utils/column.c
+++ b/text-utils/column.c
@@ -173,7 +173,6 @@ int main(int argc, char **argv)
 		default:
 			usage(EXIT_FAILURE);
 	}
-	argc -= optind;
 	argv += optind;
 
 	if (!*argv)
-- 
1.8.3.2


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

* [PATCH 24/34] hwclock: assigned value is never read [clang-analyzer]
  2013-07-07 19:54 [PATCH 00/34] pull: make printing quicker, and clang analysis Sami Kerola
                   ` (21 preceding siblings ...)
  2013-07-07 19:54 ` [PATCH 23/34] column: " Sami Kerola
@ 2013-07-07 19:54 ` Sami Kerola
  2013-07-07 19:54 ` [PATCH 25/34] dmesg: " Sami Kerola
                   ` (10 subsequent siblings)
  33 siblings, 0 replies; 41+ messages in thread
From: Sami Kerola @ 2013-07-07 19:54 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 sys-utils/hwclock.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c
index 5dd7919..b6ceb4d 100644
--- a/sys-utils/hwclock.c
+++ b/sys-utils/hwclock.c
@@ -1729,7 +1729,6 @@ int main(int argc, char **argv)
 	}
 
 	argc -= optind;
-	argv += optind;
 
 #ifdef HAVE_LIBAUDIT
 	if (testing != TRUE) {
-- 
1.8.3.2


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

* [PATCH 25/34] dmesg: assigned value is never read [clang-analyzer]
  2013-07-07 19:54 [PATCH 00/34] pull: make printing quicker, and clang analysis Sami Kerola
                   ` (22 preceding siblings ...)
  2013-07-07 19:54 ` [PATCH 24/34] hwclock: " Sami Kerola
@ 2013-07-07 19:54 ` Sami Kerola
  2013-07-07 19:54 ` [PATCH 26/34] login: " Sami Kerola
                   ` (9 subsequent siblings)
  33 siblings, 0 replies; 41+ messages in thread
From: Sami Kerola @ 2013-07-07 19:54 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 sys-utils/dmesg.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c
index 64b1c09..85488bb 100644
--- a/sys-utils/dmesg.c
+++ b/sys-utils/dmesg.c
@@ -1349,7 +1349,6 @@ int main(int argc, char *argv[])
 		}
 	}
 	argc -= optind;
-	argv += optind;
 
 	if (argc > 1)
 		usage(stderr);
-- 
1.8.3.2


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

* [PATCH 26/34] login: assigned value is never read [clang-analyzer]
  2013-07-07 19:54 [PATCH 00/34] pull: make printing quicker, and clang analysis Sami Kerola
                   ` (23 preceding siblings ...)
  2013-07-07 19:54 ` [PATCH 25/34] dmesg: " Sami Kerola
@ 2013-07-07 19:54 ` Sami Kerola
  2013-07-07 19:54 ` [PATCH 27/34] sfdisk: " Sami Kerola
                   ` (8 subsequent siblings)
  33 siblings, 0 replies; 41+ messages in thread
From: Sami Kerola @ 2013-07-07 19:54 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 login-utils/login.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/login-utils/login.c b/login-utils/login.c
index 89df489..fbfc199 100644
--- a/login-utils/login.c
+++ b/login-utils/login.c
@@ -1290,7 +1290,6 @@ int main(int argc, char **argv)
 			fprintf(stderr, _("Usage: login [-p] [-h <host>] [-H] [[-f] <username>]\n"));
 			exit(EXIT_FAILURE);
 		}
-	argc -= optind;
 	argv += optind;
 
 	if (*argv) {
-- 
1.8.3.2


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

* [PATCH 27/34] sfdisk: assigned value is never read [clang-analyzer]
  2013-07-07 19:54 [PATCH 00/34] pull: make printing quicker, and clang analysis Sami Kerola
                   ` (24 preceding siblings ...)
  2013-07-07 19:54 ` [PATCH 26/34] login: " Sami Kerola
@ 2013-07-07 19:54 ` Sami Kerola
  2013-07-07 19:54 ` [PATCH 28/34] sulogin: fix memory leak [clang-analyzer] Sami Kerola
                   ` (7 subsequent siblings)
  33 siblings, 0 replies; 41+ messages in thread
From: Sami Kerola @ 2013-07-07 19:54 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 fdisks/sfdisk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fdisks/sfdisk.c b/fdisks/sfdisk.c
index 6b757a7..152e5f5 100644
--- a/fdisks/sfdisk.c
+++ b/fdisks/sfdisk.c
@@ -1505,7 +1505,7 @@ msdos_partition(char *dev, int fd, unsigned long start, struct disk_desc *z) {
     struct partition pt;
     struct sector *s;
     struct part_desc *partitions = &(z->partitions[0]);
-    int pno = z->partno;
+    int pno;
     int bsd_later = 1;
     unsigned short sig, magic;
 #ifdef __linux__
-- 
1.8.3.2


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

* [PATCH 28/34] sulogin: fix memory leak [clang-analyzer]
  2013-07-07 19:54 [PATCH 00/34] pull: make printing quicker, and clang analysis Sami Kerola
                   ` (25 preceding siblings ...)
  2013-07-07 19:54 ` [PATCH 27/34] sfdisk: " Sami Kerola
@ 2013-07-07 19:54 ` Sami Kerola
  2013-07-07 19:54 ` [PATCH 29/34] agetty: " Sami Kerola
                   ` (6 subsequent siblings)
  33 siblings, 0 replies; 41+ messages in thread
From: Sami Kerola @ 2013-07-07 19:54 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

And make code a little bit more robust.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 login-utils/sulogin-consoles.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/login-utils/sulogin-consoles.c b/login-utils/sulogin-consoles.c
index d0f0eab..a131e79 100644
--- a/login-utils/sulogin-consoles.c
+++ b/login-utils/sulogin-consoles.c
@@ -719,7 +719,7 @@ console:
 
 fallback:
 	if (fallback >= 0) {
-		const char *name;
+		const char *name, *n;
 		struct console *console;
 
 		if (device && *device != '\0')
@@ -729,7 +729,11 @@ fallback:
 		if (!name)
 			name = "/dev/tty";
 
-		rc = append_console(consoles, strdup(name));
+		n = strdup(name);
+		if (!n)
+			return -ENOMEM;
+		rc = append_console(consoles, n);
+		free(n);
 		if (rc < 0)
 			return rc;
 		if (list_empty(consoles))
-- 
1.8.3.2


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

* [PATCH 29/34] agetty: fix memory leak [clang-analyzer]
  2013-07-07 19:54 [PATCH 00/34] pull: make printing quicker, and clang analysis Sami Kerola
                   ` (26 preceding siblings ...)
  2013-07-07 19:54 ` [PATCH 28/34] sulogin: fix memory leak [clang-analyzer] Sami Kerola
@ 2013-07-07 19:54 ` Sami Kerola
  2013-07-07 19:54 ` [PATCH 30/34] dmesg: add missing initializer [clang-analyzer] Sami Kerola
                   ` (5 subsequent siblings)
  33 siblings, 0 replies; 41+ messages in thread
From: Sami Kerola @ 2013-07-07 19:54 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

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

diff --git a/term-utils/agetty.c b/term-utils/agetty.c
index 054a1dd..5a75433 100644
--- a/term-utils/agetty.c
+++ b/term-utils/agetty.c
@@ -463,9 +463,11 @@ static char *replace_u(char *str, char *username)
 		}
 		sz = strlen(str);
 
-		if (p == str && sz == 2)
+		if (p == str && sz == 2) {
 			/* 'str' contains only '\u' */
+			free(old);
 			return username;
+		}
 
 		tp = entry = malloc(sz + usz);
 		if (!tp)
-- 
1.8.3.2


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

* [PATCH 30/34] dmesg: add missing initializer [clang-analyzer]
  2013-07-07 19:54 [PATCH 00/34] pull: make printing quicker, and clang analysis Sami Kerola
                   ` (27 preceding siblings ...)
  2013-07-07 19:54 ` [PATCH 29/34] agetty: " Sami Kerola
@ 2013-07-07 19:54 ` Sami Kerola
  2013-07-07 19:54 ` [PATCH 31/34] ul: use correct types Sami Kerola
                   ` (4 subsequent siblings)
  33 siblings, 0 replies; 41+ messages in thread
From: Sami Kerola @ 2013-07-07 19:54 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 misc-utils/uuidd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/misc-utils/uuidd.c b/misc-utils/uuidd.c
index d0ecb95..0427e46 100644
--- a/misc-utils/uuidd.c
+++ b/misc-utils/uuidd.c
@@ -480,7 +480,7 @@ int main(int argc, char **argv)
 	const char	*socket_path = UUIDD_SOCKET_PATH;
 	const char	*pidfile_path = NULL;
 	const char	*pidfile_path_param = NULL;
-	const char	*err_context;
+	const char	*err_context = _("unexpected error");
 	char		buf[1024], *cp;
 	char		str[UUID_STR_LEN];
 	uuid_t		uu;
-- 
1.8.3.2


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

* [PATCH 31/34] ul: use correct types
  2013-07-07 19:54 [PATCH 00/34] pull: make printing quicker, and clang analysis Sami Kerola
                   ` (28 preceding siblings ...)
  2013-07-07 19:54 ` [PATCH 30/34] dmesg: add missing initializer [clang-analyzer] Sami Kerola
@ 2013-07-07 19:54 ` Sami Kerola
  2013-07-07 19:54 ` [PATCH 32/34] ul: use string printing function Sami Kerola
                   ` (3 subsequent siblings)
  33 siblings, 0 replies; 41+ messages in thread
From: Sami Kerola @ 2013-07-07 19:54 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

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

diff --git a/text-utils/ul.c b/text-utils/ul.c
index c2c19f6..add419b 100644
--- a/text-utils/ul.c
+++ b/text-utils/ul.c
@@ -464,11 +464,11 @@ static void iattr(void)
 {
 	register int i;
 #ifdef __GNUC__
-	register char *lbuf = __builtin_alloca((maxcol+1)*sizeof(char));
+	register wchar_t *lbuf = __builtin_alloca((maxcol+1)*sizeof(wchar_t));
 #else
-	char lbuf[BUFSIZ];
+	wchar_t lbuf[BUFSIZ];
 #endif
-	register char *cp = lbuf;
+	register wchar_t *cp = lbuf;
 
 	for (i = 0; i < maxcol; i++)
 		switch (obuf[i].c_mode) {
-- 
1.8.3.2


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

* [PATCH 32/34] ul: use string printing function
  2013-07-07 19:54 [PATCH 00/34] pull: make printing quicker, and clang analysis Sami Kerola
                   ` (29 preceding siblings ...)
  2013-07-07 19:54 ` [PATCH 31/34] ul: use correct types Sami Kerola
@ 2013-07-07 19:54 ` Sami Kerola
  2013-07-07 19:54 ` [PATCH 33/34] column: dereference of null pointer [clang-analyzer] Sami Kerola
                   ` (2 subsequent siblings)
  33 siblings, 0 replies; 41+ messages in thread
From: Sami Kerola @ 2013-07-07 19:54 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Use of for loop and printing a string character by character is slower
than to print whole string with single function.

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

diff --git a/text-utils/ul.c b/text-utils/ul.c
index add419b..a69ac8a 100644
--- a/text-utils/ul.c
+++ b/text-utils/ul.c
@@ -448,8 +448,7 @@ static void overstrike(void)
 	putwchar('\r');
 	for (*cp = ' '; *cp == ' '; cp--)
 		*cp = 0;
-	for (cp = lbuf; *cp; cp++)
-		putwchar(*cp);
+	fputws(lbuf, stdout);
 	if (hadbold) {
 		putwchar('\r');
 		for (cp = lbuf; *cp; cp++)
@@ -482,8 +481,7 @@ static void iattr(void)
 		}
 	for (*cp = ' '; *cp == ' '; cp--)
 		*cp = 0;
-	for (cp = lbuf; *cp; cp++)
-		putwchar(*cp);
+	fputws(lbuf, stdout);
 	putwchar('\n');
 }
 
-- 
1.8.3.2


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

* [PATCH 33/34] column: dereference of null pointer [clang-analyzer]
  2013-07-07 19:54 [PATCH 00/34] pull: make printing quicker, and clang analysis Sami Kerola
                   ` (30 preceding siblings ...)
  2013-07-07 19:54 ` [PATCH 32/34] ul: use string printing function Sami Kerola
@ 2013-07-07 19:54 ` Sami Kerola
  2013-07-07 19:54 ` [PATCH 34/34] more: use variable lenght printf field width to print blanks Sami Kerola
  2013-07-09 12:58 ` [PATCH 00/34] pull: make printing quicker, and clang analysis Karel Zak
  33 siblings, 0 replies; 41+ messages in thread
From: Sami Kerola @ 2013-07-07 19:54 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 text-utils/column.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/text-utils/column.c b/text-utils/column.c
index 25a2286..3909887 100644
--- a/text-utils/column.c
+++ b/text-utils/column.c
@@ -392,7 +392,7 @@ static int input(FILE *fp, int *maxlength, wchar_t ***list, int *entries)
 			continue;
 		}
 		lineno++;
-		if (!feof(fp))
+		if (!feof(fp) && p)
 			*p = '\0';
 		len = wcs_width(buf);	/* len = p - buf; */
 		if (*maxlength < len)
-- 
1.8.3.2


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

* [PATCH 34/34] more: use variable lenght printf field width to print blanks
  2013-07-07 19:54 [PATCH 00/34] pull: make printing quicker, and clang analysis Sami Kerola
                   ` (31 preceding siblings ...)
  2013-07-07 19:54 ` [PATCH 33/34] column: dereference of null pointer [clang-analyzer] Sami Kerola
@ 2013-07-07 19:54 ` Sami Kerola
  2013-07-09 12:58 ` [PATCH 00/34] pull: make printing quicker, and clang analysis Karel Zak
  33 siblings, 0 replies; 41+ messages in thread
From: Sami Kerola @ 2013-07-07 19:54 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

This makes program to run a little faster.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 text-utils/more.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/text-utils/more.c b/text-utils/more.c
index 62de6ad..1137ea7 100644
--- a/text-utils/more.c
+++ b/text-utils/more.c
@@ -1059,8 +1059,7 @@ void erasep(register int col)
 		if (!dumb && eraseln)
 			my_putstring(eraseln);
 		else
-			for (col = promptlen - col; col > 0; col--)
-				putchar(' ');
+			printf("%*s", promptlen - col, "");
 	}
 	promptlen = 0;
 }
-- 
1.8.3.2


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

* Re: [PATCH 13/34] libmount: fix memory leak [clang-analyzer]
  2013-07-07 19:54 ` [PATCH 13/34] libmount: fix memory leak [clang-analyzer] Sami Kerola
@ 2013-07-08  8:02   ` Karel Zak
  0 siblings, 0 replies; 41+ messages in thread
From: Karel Zak @ 2013-07-08  8:02 UTC (permalink / raw)
  To: Sami Kerola; +Cc: util-linux

On Sun, Jul 07, 2013 at 08:54:28PM +0100, Sami Kerola wrote:
> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
> ---
>  libmount/src/utils.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/libmount/src/utils.c b/libmount/src/utils.c
> index 1655764..7714b50 100644
> --- a/libmount/src/utils.c
> +++ b/libmount/src/utils.c
> @@ -198,6 +198,7 @@ int mnt_chdir_to_parent(const char *target, char **filename)
>  		else
>  			memcpy(*filename, last, strlen(last) + 1);
>  	}
    else

> +	free(buf);
>  	return 0;

 Please, read the code and don't blindly follow analyzers.

    Karel

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

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

* Re: [PATCH 21/34] mesg: assigned value is never read [clang-analyzer]
  2013-07-07 19:54 ` [PATCH 21/34] mesg: " Sami Kerola
@ 2013-07-08  8:23   ` Karel Zak
  0 siblings, 0 replies; 41+ messages in thread
From: Karel Zak @ 2013-07-08  8:23 UTC (permalink / raw)
  To: Sami Kerola; +Cc: util-linux

On Sun, Jul 07, 2013 at 08:54:36PM +0100, Sami Kerola wrote:
> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
> ---
>  term-utils/mesg.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/term-utils/mesg.c b/term-utils/mesg.c
> index 430236f..638a8c7 100644
> --- a/term-utils/mesg.c
> +++ b/term-utils/mesg.c
> @@ -115,7 +115,6 @@ int main(int argc, char *argv[])
>  			usage(stderr);
>  		}
>  
> -	argc -= optind;
>  	argv += optind;

 This is technically correct change, but I don't think it makes code
 more robust. The argv[] and argc are twins and it's bad coding style
 manner to divide the relation.

    Karel


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

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

* Re: [PATCH 03/34] include: copy unlocked-io.h from gnulib
  2013-07-07 19:54 ` [PATCH 03/34] include: copy unlocked-io.h from gnulib Sami Kerola
@ 2013-07-08 20:21   ` Kay Sievers
  2013-07-09  6:37     ` Sami Kerola
  0 siblings, 1 reply; 41+ messages in thread
From: Kay Sievers @ 2013-07-08 20:21 UTC (permalink / raw)
  To: Sami Kerola; +Cc: util-linux

On Sun, Jul 7, 2013 at 9:54 PM, Sami Kerola <kerolasa@iki.fi> wrote:
> At the moment util-linux command are not threading, which means they can
> safely use thread-unsafe IO system calls which should make printing
> quicker.

Do you have numbers about the assumption that this will produce better
results on Linux?

Uncontended mutexes/futexes on Linux probably might not really show
up. Maybe in inner loops, not sure. Would be nice to know ...

Kay

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

* Re: [PATCH 03/34] include: copy unlocked-io.h from gnulib
  2013-07-08 20:21   ` Kay Sievers
@ 2013-07-09  6:37     ` Sami Kerola
  2013-07-09  9:16       ` Kay Sievers
  0 siblings, 1 reply; 41+ messages in thread
From: Sami Kerola @ 2013-07-09  6:37 UTC (permalink / raw)
  To: Kay Sievers; +Cc: util-linux

On 8 July 2013 21:21, Kay Sievers <kay@vrfy.org> wrote:
> On Sun, Jul 7, 2013 at 9:54 PM, Sami Kerola <kerolasa@iki.fi> wrote:
>> At the moment util-linux command are not threading, which means they can
>> safely use thread-unsafe IO system calls which should make printing
>> quicker.
>
> Do you have numbers about the assumption that this will produce better
> results on Linux?
>
> Uncontended mutexes/futexes on Linux probably might not really show
> up. Maybe in inner loops, not sure. Would be nice to know ...

I did not do much testing, and to be honest results were slightly
disappointing. With simple 'time command < big_file' most of the
commands did not show measurable difference, but as a junior
programmer I thought the _unlocked would be beneficial for single
thread programs. As such assumptions are not preferred I will set up
some sort of test, which will try to accomplish what is the difference
of each locked vs _unlocked function call with various output sizes.
Assuming I get the test right it should not be a big deal to run it on
various systems I have access.

Karel could you hold these patches until there is more substance to
justify merge or reject.

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

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

* Re: [PATCH 03/34] include: copy unlocked-io.h from gnulib
  2013-07-09  6:37     ` Sami Kerola
@ 2013-07-09  9:16       ` Kay Sievers
  2013-07-13 22:10         ` Sami Kerola
  0 siblings, 1 reply; 41+ messages in thread
From: Kay Sievers @ 2013-07-09  9:16 UTC (permalink / raw)
  To: kerolasa; +Cc: util-linux

On Tue, Jul 9, 2013 at 8:37 AM, Sami Kerola <kerolasa@iki.fi> wrote:
> On 8 July 2013 21:21, Kay Sievers <kay@vrfy.org> wrote:
>> On Sun, Jul 7, 2013 at 9:54 PM, Sami Kerola <kerolasa@iki.fi> wrote:
>>> At the moment util-linux command are not threading, which means they can
>>> safely use thread-unsafe IO system calls which should make printing
>>> quicker.
>>
>> Do you have numbers about the assumption that this will produce better
>> results on Linux?
>>
>> Uncontended mutexes/futexes on Linux probably might not really show
>> up. Maybe in inner loops, not sure. Would be nice to know ...
>
> I did not do much testing, and to be honest results were slightly
> disappointing. With simple 'time command < big_file' most of the
> commands did not show measurable difference, but as a junior
> programmer I thought the _unlocked would be beneficial for single
> thread programs. As such assumptions are not preferred I will set up
> some sort of test, which will try to accomplish what is the difference
> of each locked vs _unlocked function call with various output sizes.
> Assuming I get the test right it should not be a big deal to run it on
> various systems I have access.

Here is a bit of the background, which explains a bit why uncontended
futexes (which is always the case in single-threaded programs) might
not really make a difference on common Linux architectures. They will
not even involve the kernel, just a simple instruction:
  http://lwn.net/Articles/360699/

Kay

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

* Re: [PATCH 00/34] pull: make printing quicker, and clang analysis
  2013-07-07 19:54 [PATCH 00/34] pull: make printing quicker, and clang analysis Sami Kerola
                   ` (32 preceding siblings ...)
  2013-07-07 19:54 ` [PATCH 34/34] more: use variable lenght printf field width to print blanks Sami Kerola
@ 2013-07-09 12:58 ` Karel Zak
  33 siblings, 0 replies; 41+ messages in thread
From: Karel Zak @ 2013-07-09 12:58 UTC (permalink / raw)
  To: Sami Kerola; +Cc: util-linux

On Sun, Jul 07, 2013 at 08:54:15PM +0100, Sami Kerola wrote:
>       sfdisk: make unhiding as complete as possible
>       docs: add missing options to sfdisk manual

 Applied.

>       include: copy unlocked-io.h from gnulib
>       hexdump: use unlocked io, and avoid use of printf()
>       text-utils: use unlocked io
>       misc-utils: use unlocked io
>       scriptreplay: use unlocked io
>       dmesg: use unlocked io, and avoid use of printf()
>       utmpdump: use unlocked io, and avoid use of printf()

 Postponed.

>       dmesg: inform user --show-delta and iso8601 time format does not mix
>       lib/loopdev: assigned value is never read [clang-analyzer]
>       lib/mbsalign: initializations values are never read [clang-analyzer]
>       libmount: fix memory leak [clang-analyzer]

 Fixed and applied.

>       ipcs: assigned values are never read [clang-analyzer]
>       lscpu: fix memory leak [clang-analyzer]
>       more: assigned value is never read [clang-analyzer]
>       utmpdump: assigned values are never read [clang-analyzer]
>       mkfs.cramfs: argument to free() is a constant address [clang-analyzer]
>       eject: assigned value is never read [clang-analyzer]
>       chfn: assigned value is never read [clang-analyzer]

 Applied.

>       mesg: assigned value is never read [clang-analyzer]
>       rev: assigned value is never read [clang-analyzer]
>       column: assigned value is never read [clang-analyzer]
>       hwclock: assigned value is never read [clang-analyzer]
>       dmesg: assigned value is never read [clang-analyzer]
>       login: assigned value is never read [clang-analyzer]
>       fdisk: assigned value is never read [clang-analyzer]

 Ignored as keep argv and argc consistent seems better.

>       sulogin: fix memory leak [clang-analyzer]
>       agetty: fix memory leak [clang-analyzer]
>       dmesg: add missing initializer [clang-analyzer]
        ^^^^^
        uuidd:

 Fixed & applied.

>       ul: use correct types
>       ul: use string printing function
>       column: dereference of null pointer [clang-analyzer]
>       more: use variable lenght printf field width to print blanks

 Applied (with some changes).

    Karel


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

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

* Re: [PATCH 03/34] include: copy unlocked-io.h from gnulib
  2013-07-09  9:16       ` Kay Sievers
@ 2013-07-13 22:10         ` Sami Kerola
  0 siblings, 0 replies; 41+ messages in thread
From: Sami Kerola @ 2013-07-13 22:10 UTC (permalink / raw)
  To: Kay Sievers; +Cc: util-linux

On 9 July 2013 10:16, Kay Sievers <kay@vrfy.org> wrote:
> On Tue, Jul 9, 2013 at 8:37 AM, Sami Kerola <kerolasa@iki.fi> wrote:
>> On 8 July 2013 21:21, Kay Sievers <kay@vrfy.org> wrote:
>>> On Sun, Jul 7, 2013 at 9:54 PM, Sami Kerola <kerolasa@iki.fi> wrote:
>>>> At the moment util-linux command are not threading, which means they can
>>>> safely use thread-unsafe IO system calls which should make printing
>>>> quicker.
>>>
>>> Do you have numbers about the assumption that this will produce better
>>> results on Linux?
>>>
>>> Uncontended mutexes/futexes on Linux probably might not really show
>>> up. Maybe in inner loops, not sure. Would be nice to know ...
>>
>> I did not do much testing, and to be honest results were slightly
>> disappointing. With simple 'time command < big_file' most of the
>> commands did not show measurable difference, but as a junior
>> programmer I thought the _unlocked would be beneficial for single
>> thread programs. As such assumptions are not preferred I will set up
>> some sort of test, which will try to accomplish what is the difference
>> of each locked vs _unlocked function call with various output sizes.
>> Assuming I get the test right it should not be a big deal to run it on
>> various systems I have access.
>
> Here is a bit of the background, which explains a bit why uncontended
> futexes (which is always the case in single-threaded programs) might
> not really make a difference on common Linux architectures. They will
> not even involve the kernel, just a simple instruction:
>   http://lwn.net/Articles/360699/

Hello Kay, Karel, and others who like statistics,

This is how I created numbers, and analysed them.

http://www.iki.fi/kerolasa/locked_vs_unlocked_io.tar.xz

Replicating results should be easy enough.  Other than the usual
developer tools I used R to visualize the numbers.  I have doubts my test
is measuring something else than what I hope it to measure, if so
comments about bias are welcome.

When I look the measurement

http://www.iki.fi/kerolasa/locked_vs_unlocked_io.png

it does, and doesn't, make sense.  As one could expect unlocked IO is
slightly quicker, when comparing mean run time.  But locked IO has much
more predictable run time, although some requests form quite long tail of
slow runs.  When looking slow runs the unlocked tail is heavier.

Conclusion.  Maybe my test is broken, or performance characteristics of
these two functions are dissimilar enough that comparison is a bit like
with apples and oranges.

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

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

end of thread, other threads:[~2013-07-13 22:11 UTC | newest]

Thread overview: 41+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-07 19:54 [PATCH 00/34] pull: make printing quicker, and clang analysis Sami Kerola
2013-07-07 19:54 ` [PATCH 01/34] sfdisk: make unhiding as complete as possible Sami Kerola
2013-07-07 19:54 ` [PATCH 02/34] docs: add missing options to sfdisk manual Sami Kerola
2013-07-07 19:54 ` [PATCH 03/34] include: copy unlocked-io.h from gnulib Sami Kerola
2013-07-08 20:21   ` Kay Sievers
2013-07-09  6:37     ` Sami Kerola
2013-07-09  9:16       ` Kay Sievers
2013-07-13 22:10         ` Sami Kerola
2013-07-07 19:54 ` [PATCH 04/34] hexdump: use unlocked io, and avoid use of printf() Sami Kerola
2013-07-07 19:54 ` [PATCH 05/34] text-utils: use unlocked io Sami Kerola
2013-07-07 19:54 ` [PATCH 06/34] misc-utils: " Sami Kerola
2013-07-07 19:54 ` [PATCH 07/34] scriptreplay: " Sami Kerola
2013-07-07 19:54 ` [PATCH 09/34] utmpdump: use unlocked io, and avoid use of printf() Sami Kerola
2013-07-07 19:54 ` [PATCH 10/34] dmesg: inform user --show-delta and iso8601 time format does not mix Sami Kerola
2013-07-07 19:54 ` [PATCH 11/34] lib/loopdev: assigned value is never read [clang-analyzer] Sami Kerola
2013-07-07 19:54 ` [PATCH 12/34] lib/mbsalign: initializations values are " Sami Kerola
2013-07-07 19:54 ` [PATCH 13/34] libmount: fix memory leak [clang-analyzer] Sami Kerola
2013-07-08  8:02   ` Karel Zak
2013-07-07 19:54 ` [PATCH 14/34] ipcs: assigned values are never read [clang-analyzer] Sami Kerola
2013-07-07 19:54 ` [PATCH 15/34] lscpu: fix memory leak [clang-analyzer] Sami Kerola
2013-07-07 19:54 ` [PATCH 16/34] more: assigned value is never read [clang-analyzer] Sami Kerola
2013-07-07 19:54 ` [PATCH 17/34] utmpdump: assigned values are " Sami Kerola
2013-07-07 19:54 ` [PATCH 18/34] mkfs.cramfs: argument to free() is a constant address [clang-analyzer] Sami Kerola
2013-07-07 19:54 ` [PATCH 19/34] eject: assigned value is never read [clang-analyzer] Sami Kerola
2013-07-07 19:54 ` [PATCH 20/34] chfn: " Sami Kerola
2013-07-07 19:54 ` [PATCH 21/34] mesg: " Sami Kerola
2013-07-08  8:23   ` Karel Zak
2013-07-07 19:54 ` [PATCH 22/34] rev: " Sami Kerola
2013-07-07 19:54 ` [PATCH 23/34] column: " Sami Kerola
2013-07-07 19:54 ` [PATCH 24/34] hwclock: " Sami Kerola
2013-07-07 19:54 ` [PATCH 25/34] dmesg: " Sami Kerola
2013-07-07 19:54 ` [PATCH 26/34] login: " Sami Kerola
2013-07-07 19:54 ` [PATCH 27/34] sfdisk: " Sami Kerola
2013-07-07 19:54 ` [PATCH 28/34] sulogin: fix memory leak [clang-analyzer] Sami Kerola
2013-07-07 19:54 ` [PATCH 29/34] agetty: " Sami Kerola
2013-07-07 19:54 ` [PATCH 30/34] dmesg: add missing initializer [clang-analyzer] Sami Kerola
2013-07-07 19:54 ` [PATCH 31/34] ul: use correct types Sami Kerola
2013-07-07 19:54 ` [PATCH 32/34] ul: use string printing function Sami Kerola
2013-07-07 19:54 ` [PATCH 33/34] column: dereference of null pointer [clang-analyzer] Sami Kerola
2013-07-07 19:54 ` [PATCH 34/34] more: use variable lenght printf field width to print blanks Sami Kerola
2013-07-09 12:58 ` [PATCH 00/34] pull: make printing quicker, and clang analysis Karel Zak

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.