pull: various small changes
Subsystems (2)
cover pull: various small changes
Hello,
Here's few changes that I have been holding back while the project was having release freeze. Most of the changes are related to various warnings noticed before release, but that I did not think are important enough to be sent while seeking for stability. Functional improvements include rename(1) shortcut to exit, and uuidgen(1) date parsing option. Even if everything else is rejected I really hope these two are accepted.
----------------------------------------------------------------
The following changes since commit f8416301c195d50a21cb54d9ea9abeccc40f9ee7:
libmount: use mount table filter on --no-canonicalize (2017-06-07 11:35:26 +0200)
are available in the git repository at:
git://github.com/kerolasa/lelux-utiliteetit.git 2017wk23
for you to fetch changes up to 53949f09430181beee4fb9f546d9a31313f4fd68:
lib: remove _RLD_ from forbid environment variable list (2017-06-08 20:42:20 +0100)
----------------------------------------------------------------
Sami Kerola (11):
misc: fallthrough fixes
line: do not print new line if nothing else was printed
rename: notice when expression and replacement are the same string
uuidgen: slice up the usage text
uuidgen: add --date option to display time when uuid was generated
isosize: avoid reading more data than what is needed
misc: fix reassigned values before old ones has been used [cppcheck]
losetup: add missing initializer [clang]
misc: remove stray semicolons
lib: simplify cpuset if clauses that return
lib: remove _RLD_ from forbid environment variable list
bash-completion/uuidgen | 5 ++- disk-utils/cfdisk.c | 10 +++--- disk-utils/fdisk-menu.c | 2 +- disk-utils/isosize.c | 57 ++++++--------------------------- disk-utils/mkfs.cramfs.c | 2 +- disk-utils/mkfs.minix.c | 2 +- disk-utils/sfdisk.c | 6 ++-- include/c.h | 18 +++++++++++ lib/cpuset.c | 12 +++---- lib/env.c | 1 - lib/mbsalign.c | 2 +- libblkid/src/devno.c | 2 +- libblkid/src/probe.c | 2 +- libblkid/src/superblocks/adaptec_raid.c | 2 +- libblkid/src/topology/md.c | 4 +-- libfdisk/src/gpt.c | 2 +- libfdisk/src/script.c | 2 +- libmount/src/btrfs.c | 6 ++-- libmount/src/cache.c | 6 ++-- libmount/src/context.c | 2 +- libmount/src/context_mount.c | 2 +- libmount/src/context_umount.c | 4 +-- libmount/src/optstr.c | 2 +- libmount/src/tab_diff.c | 4 +-- libmount/src/tab_update.c | 2 +- libsmartcols/src/column.c | 4 +-- libsmartcols/src/table_print.c | 2 +- login-utils/last.c | 2 +- login-utils/lslogins.c | 4 +-- login-utils/su-common.c | 1 + login-utils/sulogin.c | 7 ++-- misc-utils/Makemodule.am | 2 +- misc-utils/cal.c | 8 ++--- misc-utils/findmnt-verify.c | 2 +- misc-utils/findmnt.c | 10 +++--- misc-utils/lsblk.c | 2 +- misc-utils/rename.c | 6 ++-- misc-utils/test_uuidd.c | 2 +- misc-utils/uuidgen.1 | 8 +++++ misc-utils/uuidgen.c | 47 ++++++++++++++++++++++++--- sys-utils/flock.c | 2 +- sys-utils/hwclock.c | 3 +- sys-utils/ipcrm.c | 3 ++ sys-utils/losetup.c | 4 +-- sys-utils/lsipc.c | 2 +- sys-utils/nsenter.c | 2 +- sys-utils/setarch.c | 2 +- sys-utils/swapon.c | 2 +- sys-utils/unshare.c | 4 +-- term-utils/agetty.c | 4 +-- term-utils/script.c | 4 +-- term-utils/wall.c | 2 +- tests/expected/uuid/uuidgen | 6 ++++ tests/ts/uuid/uuidgen | 10 ++++++ text-utils/column.c | 2 +- text-utils/hexdump-parse.c | 2 +- text-utils/line.c | 6 ++-- text-utils/more.c | 5 +-- text-utils/pg.c | 4 +-- text-utils/ul.c | 4 +-- 60 files changed, 195 insertions(+), 144 deletions(-)
Signature · 1 line
2.13.1
PATCH 1/11 misc: fallthrough fixes
Reference: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=7652
Reference: https://developers.redhat.com/blog/2017/03/10/wimplicit-fallthrough-in-gcc-7/
--- disk-utils/cfdisk.c | 8 ++++---- disk-utils/fdisk-menu.c | 2 +- disk-utils/mkfs.cramfs.c | 2 +- disk-utils/mkfs.minix.c | 2 +- disk-utils/sfdisk.c | 6 +++--- include/c.h | 18 ++++++++++++++++++ libblkid/src/topology/md.c | 4 ++-- libsmartcols/src/table_print.c | 2 +- login-utils/last.c | 2 +- login-utils/lslogins.c | 4 ++-- login-utils/su-common.c | 1 + login-utils/sulogin.c | 7 +++---- misc-utils/cal.c | 8 ++++---- misc-utils/findmnt.c | 2 +- misc-utils/lsblk.c | 2 +- misc-utils/rename.c | 3 +-- sys-utils/flock.c | 2 +- sys-utils/hwclock.c | 3 ++- sys-utils/ipcrm.c | 3 +++ sys-utils/lsipc.c | 2 +- sys-utils/nsenter.c | 2 +- sys-utils/setarch.c | 2 +- sys-utils/unshare.c | 2 +- term-utils/agetty.c | 4 ++-- term-utils/script.c | 4 ++-- text-utils/hexdump-parse.c | 2 +- text-utils/more.c | 5 +++-- text-utils/pg.c | 4 ++-- text-utils/ul.c | 4 ++-- 29 files changed, 67 insertions(+), 45 deletions(-)
disk-utils/cfdisk.c +4 -4
@@ -1496,7 +1496,7 @@ static int ui_menu_move(struct cfdisk *cf, int key)ui_menu_goto (cf, (int ) m->idx - m->page_sz);return 0 ; } -/* fallthrough */ +UL_FALLTHROUGH ;case KEY_HOME :ui_menu_goto (cf,0 );return 0 ;
@@ -1505,7 +1505,7 @@ static int ui_menu_move(struct cfdisk *cf, int key)ui_menu_goto (cf, m->idx + m->page_sz);return 0 ; } -/* fallthrough */ +UL_FALLTHROUGH ;case KEY_END :ui_menu_goto (cf, m->nitems);return 0 ;
@@ -2503,7 +2503,7 @@ static int ui_run(struct cfdisk *cf)ui_table_goto (cf, (int ) cf->lines_idx - cf->page_sz);break ; } -/* fallthrough */ +UL_FALLTHROUGH ;case KEY_HOME :ui_table_goto (cf,0 );break ;
@@ -2512,7 +2512,7 @@ static int ui_run(struct cfdisk *cf)ui_table_goto (cf, cf->lines_idx + cf->page_sz);break ; } -/* fallthrough */ +UL_FALLTHROUGH ;case KEY_END :ui_table_goto (cf, (int ) cf->nlines -1 );break ;
disk-utils/fdisk-menu.c +1 -1
@@ -579,7 +579,7 @@ static int generic_menu_cb(struct fdisk_context **cxt0, rc =fdisk_reread_partition_table (cxt);if (!rc) rc =fdisk_deassign_device (cxt,0 ); -/* fallthrough */ +UL_FALLTHROUGH ;case 'q' :fdisk_unref_context (cxt);fputc ('\n' , stdout);
disk-utils/mkfs.cramfs.c +1 -1
@@ -123,7 +123,7 @@ struct entry {#define CRAMFS_OFFSET_WIDTH 26/* Input status of 0 to print help and exit without an error. */ -static void +static void __attribute__((__noreturn__))usage (int status) {FILE *stream = status ? stderr : stdout;
disk-utils/mkfs.minix.c +1 -1
@@ -765,7 +765,7 @@ int main(int argc, char ** argv)break ;case 'v' :/* kept for backwards compatibility */ warnx (_ ("-v is ambiguous, use '-2' instead" )); -/* fallthrough */ +UL_FALLTHROUGH ;case '2' : fs_version =2 ;break ;
disk-utils/sfdisk.c +3 -3
@@ -1825,7 +1825,7 @@ static int command_fdisk(struct sfdisk *sf, int argc, char **argv)break ; } } -/* fallthrough */ +UL_FALLTHROUGH ;case SFDISK_DONE_WRITE : rc =write_changes (sf);break ;
@@ -2025,7 +2025,7 @@ int main(int argc, char *argv[])break ;case 'J' : sf->json =1 ; -/* fallthrough */ +UL_FALLTHROUGH ;case 'd' : sf->act =ACT_DUMP ;break ;
@@ -2037,7 +2037,7 @@ int main(int argc, char *argv[])break ;case 'G' :warnx (_ ("--show-pt-geometry is no more implemented. Using --show-geometry." )); -/* fallthrough */ +UL_FALLTHROUGH ;case 'g' : sf->act =ACT_SHOW_GEOM ;break ;
include/c.h +18 -0
@@ -77,6 +77,24 @@#endif /* +* Statement Attributes +*/ +#if defined(__clang__) +# ifndef __has_cpp_attribute +# define __has_cpp_attribute (x) 0 +# endif +# if __has_cpp_attribute(clang::fallthrough) +# define UL_FALLTHROUGH [[clang::fallthrough]] +# else +# define UL_FALLTHROUGH /* fall through */ +# endif +#elif defined(__GNUC__) || defined(__GNUG__) +# define UL_FALLTHROUGH __attribute__((fallthrough)) +#else +# define UL_FALLTHROUGH /* FALLTHRU */ +#endif + +/* * Force a compilation error if condition is true, but also produce a * result (of value 0 and type size_t), so the expression can be used * e.g. in a structure initializer (or wherever else comma expressions
libblkid/src/topology/md.c +2 -2
@@ -121,11 +121,11 @@ static int probe_md_tp(blkid_probe pr,switch (md.level) {case 6 : md.raid_disks--; -/* fallthrough */ +UL_FALLTHROUGH ;case 5 :case 4 : md.raid_disks--; -/* fallthrough */ +UL_FALLTHROUGH ;case 1 :case 0 :case 10 :
libsmartcols/src/table_print.c +1 -1
@@ -1412,7 +1412,7 @@ static int initialize_printing(struct libscols_table *tb, struct libscols_buffercase SCOLS_FMT_JSON :if (tb->format ==SCOLS_FMT_JSON ) extra_bufsz += tb->nlines *3 ;/* indention */ -/* fallthrough */ +UL_FALLTHROUGH ;case SCOLS_FMT_EXPORT : {struct libscols_column *cl;
login-utils/last.c +1 -1
@@ -830,7 +830,7 @@ static void process_wtmp_file(const struct last_control *ctl, c = whydown; quit =list (ctl, &ut, lastboot, c); } -/* FALLTHRU */ +UL_FALLTHROUGH ;case DEAD_PROCESS :/*
login-utils/lslogins.c +2 -2
@@ -926,13 +926,13 @@ static struct libscols_table *setup_table(struct lslogins_control *ctl)break ;case OUT_NEWLINE :scols_table_set_column_separator (table,"\n" ); -/* fallthrough */ +UL_FALLTHROUGH ;case OUT_EXPORT :scols_table_enable_export (table,1 );break ;case OUT_NUL :scols_table_set_line_separator (table,"\0" ); -/* fallthrough */ +UL_FALLTHROUGH ;case OUT_RAW :scols_table_enable_raw (table,1 );break ;
login-utils/su-common.c +1 -0
@@ -899,6 +899,7 @@ su_main (int argc, char **argv, int mode)/* fallthrough if -u <user> is not specified, then follow * traditional su(1) behavior */ +UL_FALLTHROUGH ;case SU_MODE :if (optind < argc) new_user = argv[optind++];
login-utils/sulogin.c +3 -4
@@ -267,11 +267,11 @@ static void tcfinal(struct console *con)break ;case 1 :/* odd parity */ tio->c_cflag |=PARODD ; -/* fall through */ +UL_FALLTHROUGH ;case 2 :/* even parity */ tio->c_cflag |=PARENB ; tio->c_iflag |= (INPCK |ISTRIP ); -/* fall through */ +UL_FALLTHROUGH ;case (1 |2 ):/* no parity bit */ tio->c_cflag &= ~CSIZE ; tio->c_cflag |=CS7 ;
@@ -971,7 +971,6 @@ int main(int argc, char **argv)switch ((con->pid =fork ())) {case 0 :mask_signal (SIGCHLD ,SIG_DFL ,NULL ); -/* fall through */ nofork:setup (con);while (1 ) {
@@ -1024,7 +1023,7 @@ int main(int argc, char **argv)exit (0 );case -1 :warn (_ ("fork failed" )); -/* fall through */ +UL_FALLTHROUGH ;default :break ; }
misc-utils/cal.c +4 -4
@@ -431,7 +431,7 @@ int main(int argc, char **argv) ctl.req.day =strtos32_or_err (*argv++,_ ("illegal day value" ));if (ctl.req.day <1 ||DAYS_IN_MONTH < ctl.req.day)errx (EXIT_FAILURE ,_ ("illegal day value: use 1-%d" ),DAYS_IN_MONTH ); -/* FALLTHROUGH */ +UL_FALLTHROUGH ;case 2 :if (isdigit (**argv)) ctl.req.month =strtos32_or_err (*argv++,_ ("illegal month value: use 1-12" ));
@@ -443,7 +443,7 @@ int main(int argc, char **argv) }if (ctl.req.month <1 ||MONTHS_IN_YEAR < ctl.req.month)errx (EXIT_FAILURE ,_ ("illegal month value: use 1-12" )); -/* FALLTHROUGH */ +UL_FALLTHROUGH ;case 1 : ctl.req.year =strtos32_or_err (*argv++,_ ("illegal year value" ));if (ctl.req.year <SMALLEST_YEAR )
@@ -802,10 +802,10 @@ static void monthly(const struct cal_control *ctl)switch (ctl->num_months % ctl->months_in_row){case 1 : m1.next =NULL ; -/* fallthrough */ +UL_FALLTHROUGH ;case 2 : m2.next =NULL ; -/* fallthrough */ +UL_FALLTHROUGH ; } }for (m = &m1; m; m = m->next){
misc-utils/findmnt.c +1 -1
@@ -1458,7 +1458,7 @@ int main(int argc, char *argv[])break ;case 'M' : flags |=FL_STRICTTARGET ; -/* fallthrough */ +UL_FALLTHROUGH ;case 'T' :set_match (COL_TARGET , optarg); flags |=FL_NOSWAPMATCH ;
misc-utils/lsblk.c +1 -1
@@ -1847,7 +1847,7 @@ int main(int argc, char *argv[]) lsblk->sort_id =column_name_to_id (optarg,strlen (optarg));if (lsblk->sort_id >=0 )break ; -/* fallthrough */ +UL_FALLTHROUGH ;default :errtryhelp (EXIT_FAILURE ); }
misc-utils/rename.c +1 -2
@@ -174,7 +174,7 @@ int main(int argc, char **argv)switch (c) {case 'n' : noact =1 ; -/* fallthrough */ +UL_FALLTHROUGH ;case 'o' : nooverwrite =1 ;break ;
@@ -189,7 +189,6 @@ int main(int argc, char **argv)return EXIT_SUCCESS ;case 'h' :usage (stdout); -/* fallthrough */ default :errtryhelp (EXIT_FAILURE ); }
sys-utils/flock.c +1 -1
@@ -305,7 +305,7 @@ int main(int argc, char *argv[])if (open_flags &O_RDWR )break ; } -/* go through */ +UL_FALLTHROUGH ;default :/* Other errors */ if (filename)
sys-utils/hwclock.c +2 -1
@@ -1209,7 +1209,8 @@ static void out_version(void)* fmt, ... ), show a usage information and terminate the program * afterwards. */ -static void usage (const struct hwclock_control *ctl,const char *fmt, ...) +static void __attribute__((__noreturn__)) +usage (const struct hwclock_control *ctl,const char *fmt, ...) {FILE *usageto;va_list ap;
sys-utils/ipcrm.c +3 -0
@@ -346,6 +346,7 @@ int main(int argc, char **argv) ret++;break ; } +UL_FALLTHROUGH ;case 'm' :if (!iskey) id =strtos32_or_err (optarg,_ ("failed to parse argument" ));
@@ -359,6 +360,7 @@ int main(int argc, char **argv) ret++;break ; } +UL_FALLTHROUGH ;case 'q' :if (!iskey) id =strtos32_or_err (optarg,_ ("failed to parse argument" ));
@@ -372,6 +374,7 @@ int main(int argc, char **argv) ret++;break ; } +UL_FALLTHROUGH ;case 's' :if (!iskey) id =strtos32_or_err (optarg,_ ("failed to parse argument" ));
sys-utils/lsipc.c +1 -1
@@ -343,7 +343,7 @@ static struct libscols_table *new_table(struct lsipc_control *ctl)switch (ctl->outmode) {case OUT_NEWLINE :scols_table_set_column_separator (table,"\n" ); -/* fallthrough */ +UL_FALLTHROUGH ;case OUT_EXPORT :scols_table_enable_export (table,1 );break ;
sys-utils/nsenter.c +1 -1
@@ -65,7 +65,7 @@ static struct namespace_file { { .nstype = 0, .name = NULL, .fd = -1 } }; -static void usage (int status) +static void __attribute__((__noreturn__))usage (int status) {FILE *out = status ==EXIT_SUCCESS ? stdout : stderr;
sys-utils/setarch.c +1 -1
@@ -377,7 +377,7 @@ int main(int argc, char *argv[])return EXIT_SUCCESS ; }else warnx (_ ("unrecognized option '--list'" )); -/* fallthrough */ +UL_FALLTHROUGH ;default :errtryhelp (EXIT_FAILURE ); }
sys-utils/unshare.c +1 -1
@@ -238,7 +238,7 @@ static void bind_ns_files_from_child(pid_t *child, int fds[2]) } } -static void usage (int status) +static void __attribute__((__noreturn__))usage (int status) {FILE *out = status ==EXIT_SUCCESS ? stdout : stderr;
term-utils/agetty.c +2 -2
@@ -2041,12 +2041,12 @@ static void termio_final(struct options *op, struct termios *tp, struct chardatacase 1 :/* odd parity */ tp->c_cflag |=PARODD ; -/* do not break */ +UL_FALLTHROUGH ;case 2 :/* even parity */ tp->c_cflag |=PARENB ; tp->c_iflag |=INPCK |ISTRIP ; -/* do not break */ +UL_FALLTHROUGH ;case (1 |2 ):/* no parity bit */ tp->c_cflag &= ~CSIZE ;
term-utils/script.c +2 -2
@@ -389,9 +389,9 @@ static void handle_signal(struct script_control *ctl, int fd) }break ;case SIGTERM : -/* fallthrough */ +UL_FALLTHROUGH ;case SIGINT : -/* fallthrough */ +UL_FALLTHROUGH ;case SIGQUIT :DBG (SIGNAL ,ul_debug (" get signal SIG{TERM,INT,QUIT}" ));fprintf (stderr,_ ("\nSession terminated.\n" ));
text-utils/hexdump-parse.c +1 -1
@@ -351,7 +351,7 @@ isint: cs[3] = '\0';case 'A' : endfu = fu; fu->flags |=F_IGNORE ; -/* FALLTHROUGH */ +UL_FALLTHROUGH ;case 'a' : pr->flags =F_ADDRESS ; ++p2;
text-utils/more.c +3 -2
@@ -1270,7 +1270,7 @@ int command(char *filename, register FILE *f)break ; } lastp++; -/* fall through */ +UL_FALLTHROUGH ;case '/' :if (nlines ==0 ) nlines++;
@@ -1368,7 +1368,7 @@ int command(char *filename, register FILE *f) (char *)0);break ; } -/* fall through */ +UL_FALLTHROUGH ;default :if (dum_opt) {kill_line ();
@@ -2023,6 +2023,7 @@ int expand(char **outbuf, char *inbuf) *outstr++ = *inpstr++;break ; } +UL_FALLTHROUGH ;default : *outstr++ = c; }
text-utils/pg.c +2 -2
@@ -659,7 +659,7 @@ static void prompt(long long pageno)break ;case SEARCH_FIN : state =SEARCH ; -/* FALLTHRU */ +UL_FALLTHROUGH ;case SEARCH :if (cmd.cmdline[cmd.cmdlen -1 ] =='\\' ) { escape =1 ;
@@ -738,7 +738,7 @@ static void prompt(long long pageno)continue ; } state =COUNT ; -/* FALLTHRU */ +UL_FALLTHROUGH ;case COUNT :break ;case ADDON_FIN :
text-utils/ul.c +2 -2
@@ -208,7 +208,7 @@ int main(int argc, char **argv)default :warnx (_ ("trouble reading terminfo" )); -/* fall through to ... */ +UL_FALLTHROUGH ;case 0 :if (tflag)
@@ -317,7 +317,7 @@ static void filter(FILE *f) } obuf[col].c_char ='_' ; obuf[col].c_width =1 ; -/* fall through */ +UL_FALLTHROUGH ;case ' ' :setcol (col +1 );continue ;
Signature · 1 line
2.13.1
Re: [PATCH 01/11] misc: fallthrough fixes
Hi,
This patch looks a bit ugly, for example:
## gcc 4.8.1
CC text-utils/more-more.o../text-utils/more.c: In function ‘command’:../text-utils/more.c:1273:4: warning: empty declaration [enabled by default]
UL_FALLTHROUGH;
## icc 16.0.0
text-utils/more.c(1273): warning #1292: unknown attribute "fallthrough"
UL_FALLTHROUGH;
^Quoted 16 lines
include/c.h +8
-0@@ -77,6 +77,24 @@#endif /* +* Statement Attributes +*/ +#if defined(__clang__) +# ifndef __has_cpp_attribute +# define __has_cpp_attribute (x) 0 +# endif +# if __has_cpp_attribute(clang::fallthrough) +# define UL_FALLTHROUGH [[clang::fallthrough]]
include/c.h line 97
Quoted 10 lines
include/c.h +10
-0+# else +# define UL_FALLTHROUGH /* fall through */ +# endif +#elif defined(__GNUC__) || defined(__GNUG__) +# define UL_FALLTHROUGH __attribute__((fallthrough)) +#else +# define UL_FALLTHROUGH /* FALLTHRU */ +#endif + +/*
Maybe just simplify like this:
#ifndef __has_attribute
#define __has_attribute(x) 0
#endif
#if __has_cpp_attribute(fallthrough)
# define UL_FALLTHROUGH [[fallthrough]] #else # define UL_FALLTHROUGH /* fall through */ #endif
The attribute works without "clang::" prefix on recent gcc and clang, and maybe icc in future.
Otherwise we could check for the attribute in configure, using autoconf-archive
AX_GCC_FUNC_ATTRIBUTE(fallthrough)
https://www.gnu.org/software/autoconf-archive/ax_gcc_func_attribute.html
cu,
Rudi
Re: [PATCH 01/11] misc: fallthrough fixes
Quoted 36 lines · Ruediger Meier
Hi,
This patch looks a bit ugly, for example:
## gcc 4.8.1
CC
text-utils/more-more.o../text-utils/more.c: In function ‘command’:../text-utils/more.c:1273:4: warning: empty declaration [enabled by default]UL_FALLTHROUGH;## icc 16.0.0
text-utils/more.c(1273): warning #1292: unknown attribute "fallthrough"
UL_FALLTHROUGH; ^Quoted 18 lines
include/c.h +10
-0@@ -77,6 +77,24 @@#endif /* +* Statement Attributes +*/ +#if defined(__clang__) +# ifndef __has_cpp_attribute +# define __has_cpp_attribute (x) 0 +# endif +# if __has_cpp_attribute(clang::fallthrough) +# define UL_FALLTHROUGH [[clang::fallthrough]] +# else +# define UL_FALLTHROUGH /* fall through */
Quoted 8 lines
include/c.h line 97
Quoted 8 lines
include/c.h +8
-0+# endif +#elif defined(__GNUC__) || defined(__GNUG__) +# define UL_FALLTHROUGH __attribute__((fallthrough)) +#else +# define UL_FALLTHROUGH /* FALLTHRU */ +#endif + +/*
Sorry this was broken. But I've checked now all clang and gcc versions. Looks like for clang the warning is only enabled when using C++ (clang++). So the fallthrough warning appears currently only on gcc>=7 and this works to disable it in a compatible way:
#ifndef __has_cpp_attribute
# define __has_cpp_attribute(x) 0 #endif
#if __has_cpp_attribute(fallthrough)
# define UL_FALLTHROUGH __attribute__((fallthrough)) #else # define UL_FALLTHROUGH /* fall through */ #endif
Quoted 27 lines
Maybe just simplify like this:
#ifndef __has_attribute #define __has_attribute(x) 0#endif
#if
__has_cpp_attribute(fallthrough)# define UL_FALLTHROUGH [[fallthrough]] #else # define UL_FALLTHROUGH /* fall through */ #endifThe attribute works without "clang::" prefix on recent gcc and clang, and maybe icc in future.
Otherwise we could check for the attribute in configure, using autoconf-archive
AX_GCC_FUNC_ATTRIBUTE(fallthrough)
https://www.gnu.org/software/autoconf-archive/ax_gcc_func_attribute.htmlcu,
Rudi
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 01/11] misc: fallthrough fixes
Quoted 44 lines · On 9 June 2017 at 22:10, R=C3=BCdiger Meier <[email protected]> wrote:
Quoted 41 lines · Ruediger Meier
Hi,
This patch looks a bit ugly, for example:
## gcc 4.8.1
CC
text-utils/more-more.o../text-utils/more.c: In function =E2=80=98command=E2=80=99:../text-utils/more.c:1273:4: warning: empty declaration [enabled by default]UL_FALLTHROUGH;## icc 16.0.0
text-utils/more.c(1273): warning #1292: unknown attribute "fallthrough"
UL_FALLTHROUGH; ^Quoted 22 lines
include/c.h +15
-0@@ -77,6 +77,24 @@#endif /* +* Statement Attributes +*/ +#if defined(__clang__) +# ifndef __has_cpp_attribute +# define __has_cpp_attribute (x) 0 +# endif +# if __has_cpp_attribute(clang::fallthrough) +# define UL_FALLTHROUGH [[clang::fallthrough]] +# else +# define UL_FALLTHROUGH /* fall through */ +# endif +#elif defined(__GNUC__) || defined(__GNUG__) +# define UL_FALLTHROUGH __attribute__((fallthrough)) +#else +# define UL_FALLTHROUGH /* FALLTHRU */
Quoted 8 lines
Quoted 3 lines
include/c.h line 97
Quoted 3 lines
include/c.h +3
-0+#endif + +/* Sorry this was broken. But I've checked now all clang and gcc versions. Looks
like for clang the warning is only enabled when using C++ (clang++). So t=
he
Quoted 5 lines
fallthrough warning appears currently only on gcc>=3D7 and this works to disable
it in a compatible way:#ifndef
__has_cpp_attribute
Quoted 8 lines
# define __has_cpp_attribute(x) 0 #endif#if
__has_cpp_attribute(fallthrough)# define UL_FALLTHROUGH __attribute__((fallthrough)) #else # define UL_FALLTHROUGH /* fall through */ #endif
Thank you for review Rudi. I had a look of the c.h again and did the change a little bit differently:
#ifdef __has_cpp_attribute
# if __has_cpp_attribute(deprecated) # define UL_FALLTHROUGH __attribute__((fallthrough)) # elif __has_cpp_attribute(clang::fallthrough) # define UL_FALLTHROUGH [[clang::fallthrough]] # endif #endif #ifndef UL_FALLTHROUGH # define UL_FALLTHROUGH /* FALLTHRU */ #endif
The above is now part of my remote branch '2017wk23'.
--=20
Sami Kerola
http://www.iki.fi/kerolasa/
Re: [PATCH 01/11] misc: fallthrough fixes
Hi Sami,
Quoted 19 lines · Sami Kerola
Quoted 8 lines · Rüdiger Meier
Sorry this was broken. But I've checked now all clang and gcc versions. Looks
like for clang the warning is only enabled when using C++ (clang++). So the fallthrough warning appears currently only on gcc>=7 and this works to disable
it in a compatible way:#ifndef
__has_cpp_attributeQuoted 8 lines
# define __has_cpp_attribute(x) 0 #endif#if
__has_cpp_attribute(fallthrough)# define UL_FALLTHROUGH __attribute__((fallthrough)) #else # define UL_FALLTHROUGH /* fall through */ #endif
Quoted 5 lines
Thank you for review Rudi. I had a look of the
c.hagain and did the change a little bit differently:#ifdef
__has_cpp_attribute# if __has_cpp_attribute(deprecated)
Is this a typoo? s/deprecated/fallthrough
Quoted 3 lines
# define
UL_FALLTHROUGH__attribute__((fallthrough))# elif __has_cpp_attribute(clang::fallthrough) # define UL_FALLTHROUGH [[clang::fallthrough]]
I still wonder. Have you really seen such a fallthrough warning from clang? I've even tried with explicit -Wimplicit-fallthrough but could not get one.
As far as I understood these namespaced "clang::" attributes are for C++ only.
man clang:
Non-standard C++11 Attributes
Clang's non-standard C++11 attributes live in the clang attribute namespace
So IMO it makes no sense to use clang::fallthrough for C code.
Quoted 5 lines
# endif #endif #ifndef UL_FALLTHROUGH # define UL_FALLTHROUGH /* FALLTHRU */ #endif
BTW just for cosmetics. Maybe we should rename UL_FALLTHROUGH to __ul_fallthrough like we have already __ul_calloc_size. IMO it would look more obvious to the reader. Also I would use it without semicolon because some compilers may complain about useless ";" statements.
cu,
Rudi
Quoted 2 lines
The above is now part of my remote branch '2017wk23'.
Re: [PATCH 01/11] misc: fallthrough fixes
Quoted 10 lines · On 12 June 2017 at 09:40, R=C3=BCdiger Meier <[email protected]> wrote:
Quoted 9 lines · Sami Kerola
Quoted 5 lines · On 9 June 2017 at 22:10, R=C3=BCdiger Meier <[email protected]> wrote:
Sorry this was broken. But I've checked now all clang and gcc versions. Looks
like for clang the warning is only enabled when using C++ (clang++). So the
fallthrough warning appears currently only on gcc>=3D7 and this works t=
o
Quoted 14 lines
Quoted 14 lines
Quoted 12 lines
disable
it in a compatible way:#ifndef
__has_cpp_attribute# define __has_cpp_attribute(x) 0 #endif#if
__has_cpp_attribute(fallthrough)# define UL_FALLTHROUGH __attribute__((fallthrough)) #else # define UL_FALLTHROUGH /* fall through */ #endif
Quoted 8 lines
Quoted 5 lines
Thank you for review Rudi. I had a look of the
c.hagain and did the change a little bit differently:#ifdef
__has_cpp_attribute# if __has_cpp_attribute(deprecated)Is this a typoo? s/deprecated/fallthrough
Hi Rudi,
Yes, it was a typo. Fixed in following.
https://github.com/kerolasa/lelux-utiliteetit/commit/aa1ed6ac309a2bd6f0c537=1a3117618074e7634a
Quoted 6 lines
Quoted 3 lines
# define
UL_FALLTHROUGH__attribute__((fallthrough))# elif __has_cpp_attribute(clang::fallthrough) # define UL_FALLTHROUGH [[clang::fallthrough]]I still wonder. Have you really seen such a fallthrough warning from clan=
g?
Quoted 1 line
I've even tried with explicit -Wimplicit-fallthrough but could not get on=
e.
Quoted 10 lines
As far as I understood these namespaced "clang::" attributes are for C++ only.
man clang:
Non-standard C++11 Attributes
Clang's non-standard C++11 attributes live in the clang attribute
namespaceSo IMO it makes no sense to use
clang::fallthroughfor C code.
Removed in same commit. Strange enough I'm pretty sure that attribute worked.
Quoted 10 lines
Quoted 5 lines
# endif #endif #ifndef UL_FALLTHROUGH # define UL_FALLTHROUGH /* FALLTHRU */ #endifBTW just for cosmetics. Maybe we should rename
UL_FALLTHROUGHto__ul_fallthrough
like we have already__ul_calloc_size. IMO it would look more obvious to =
the
Quoted 1 line
reader.
I don't have strong opinion about that, changed to one you proposed.
Quoted 3 lines
Also I would use it without semicolon because some compilers may complain about
useless ";" statements.
Semicolon is removed. Whether this will fool various indent tools is someth= ing
to be seen.
--=20
Sami Kerola
http://www.iki.fi/kerolasa/
Re: [PATCH 01/11] misc: fallthrough fixes
Quoted 56 lines · Sami Kerola
Quoted 24 lines · Rüdiger Meier
Quoted 23 lines · Sami Kerola
Quoted 17 lines · Rüdiger Meier
Sorry this was broken. But I've checked now all clang and gcc versions. Looks
like for clang the warning is only enabled when using C++ (clang++). So the
fallthrough warning appears currently only on gcc>=7 and this works to disable
it in a compatible way:#ifndef
__has_cpp_attribute# define __has_cpp_attribute(x) 0 #endif#if
__has_cpp_attribute(fallthrough)# define UL_FALLTHROUGH __attribute__((fallthrough)) #else # define UL_FALLTHROUGH /* fall through */ #endifQuoted 8 lines
Quoted 5 lines
Thank you for review Rudi. I had a look of the
c.hagain and did the change a little bit differently:#ifdef
__has_cpp_attribute# if __has_cpp_attribute(deprecated)Is this a typoo? s/deprecated/fallthrough
Hi Rudi,
Yes, it was a typo. Fixed in following.
https://github.com/kerolasa/lelux-utiliteetit/commit/aa1ed6ac309a2bd6f0c5371a3117618074e7634a
Quoted 16 lines
Quoted 3 lines
# define
UL_FALLTHROUGH__attribute__((fallthrough))# elif __has_cpp_attribute(clang::fallthrough) # define UL_FALLTHROUGH [[clang::fallthrough]]I still wonder. Have you really seen such a fallthrough warning from clang? I've even tried with explicit -Wimplicit-fallthrough but could not get one.
As far as I understood these namespaced "clang::" attributes are for C++ only.
man clang:
Non-standard C++11 Attributes
Clang's non-standard C++11 attributes live in the clang attribute
namespace
Quoted 4 lines
Quoted 1 line
So IMO it makes no sense to use
clang::fallthroughfor C code.Removed in same commit. Strange enough I'm pretty sure that attribute worked.
Yes, clang does not seem to complain about clang++ attributes. I guess they don't want to introduce even more incompatibilities. Similar I've noticed that even old gcc and clang compilers accept (ignore) the option -Wimplicit-fallthrough" and probably any other warning option.
FYI I've set up a travis build script to test many gcc and clang versions. The current build logs contain your and my other pull request
https://travis-ci.org/rudimeier/util-linux/builds/242109953
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
# endif #endif #ifndef UL_FALLTHROUGH # define UL_FALLTHROUGH /* FALLTHRU */ #endif
Quoted 6 lines
Quoted 4 lines
BTW just for cosmetics. Maybe we should rename
UL_FALLTHROUGHto__ul_fallthrough
like we have already__ul_calloc_size. IMO it would look more obvious to the reader.I don't have strong opinion about that, changed to one you proposed.
Thanks, let's see whether Karel likes this attribute at all ;)
Quoted 7 lines
Quoted 3 lines
Also I would use it without semicolon because some compilers may complain about
useless ";" statements.Semicolon is removed. Whether this will fool various indent tools is something to be seen.
Karel Zak
maintainerRe: [PATCH 01/11] misc: fallthrough fixes
Quoted 8 lines · Rüdiger Meier
Quoted 6 lines
Quoted 4 lines
BTW just for cosmetics. Maybe we should rename
UL_FALLTHROUGHto__ul_fallthrough
like we have already__ul_calloc_size. IMO it would look more obvious to the reader.I don't have strong opinion about that, changed to one you proposed.
Thanks, let's see whether Karel likes this attribute at all ;)
Hmm...
I don't like "meta-programming" where language keywords are replaced by local macros, for example we have fallback (in c.h) for all __attribute__ rather than define local macro for all attributes.
__attribute__((fallthrough))
should be fine on non-__GNUC__ as in this case __attribute__ is empty macro (see c.h).
Yes, __ul_fallthrough seems better, and __attribute__((fallthrough)) would be the best :-)
It's strange if clang will use a different syntax for the same things. IMHO it would be better to ignore clang for this attribute.
And I'm not sure if the change is compatible with coverity-scan where comment line /* fallthrough */ is required, but this not so important (coverity is maintained, so attribute will be supported one day...).
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
Re: [PATCH 01/11] misc: fallthrough fixes
Quoted 18 lines · Karel Zak
Quoted 8 lines · Rüdiger Meier
Quoted 6 lines
Quoted 4 lines
BTW just for cosmetics. Maybe we should rename
UL_FALLTHROUGHto__ul_fallthrough
like we have already__ul_calloc_size. IMO it would look more obvious to the reader.I don't have strong opinion about that, changed to one you proposed.
Thanks, let's see whether Karel likes this attribute at all ;)
Hmm...
I don't like "meta-programming" where language keywords are replaced by local macros, for example we have fallback (in
c.h) for all__attribute__rather than define local macro for all attributes.__attribute__((fallthrough))
Quoted 8 lines
should be fine on non-__GNUC__ as in this case
__attribute__is empty macro (seec.h).Yes,
__ul_fallthroughseems better, and __attribute__((fallthrough)) would be the best :-)It's strange if clang will use a different syntax for the same things. IMHO it would be better to ignore clang for this attribute.
Yes, Sami's last version just ignores clang. Seems that the different syntax was for C++ only.
So branch 2017wk23 from [email protected]:kerolasa/lelux-utiliteetit.git is the last version for merging.
Quoted 6 lines
And I'm not sure if the change is compatible with coverity-scan where comment line /* fallthrough */ is required, but this not so important (coverity is maintained, so attribute will be supported one day...).
Karel
Karel Zak
maintainerRe: [PATCH 01/11] misc: fallthrough fixes
Quoted 27 lines · Rüdiger Meier
Quoted 24 lines · Karel Zak
Quoted 8 lines · Rüdiger Meier
Quoted 6 lines
Quoted 4 lines
BTW just for cosmetics. Maybe we should rename
UL_FALLTHROUGHto__ul_fallthrough
like we have already__ul_calloc_size. IMO it would look more obvious to the reader.I don't have strong opinion about that, changed to one you proposed.
Thanks, let's see whether Karel likes this attribute at all ;)
Hmm...
I don't like "meta-programming" where language keywords are replaced by local macros, for example we have fallback (in
c.h) for all__attribute__rather than define local macro for all attributes.__attribute__((fallthrough))should be fine on non-__GNUC__ as in this case
__attribute__is empty macro (seec.h).Yes,
__ul_fallthroughseems better, and __attribute__((fallthrough)) would be the best :-)
Quoted 8 lines
Quoted 2 lines
It's strange if clang will use a different syntax for the same things. IMHO it would be better to ignore clang for this attribute.
Yes, Sami's last version just ignores clang. Seems that the different syntax was for C++ only.
So branch 2017wk23 from [email protected]:kerolasa/lelux-utiliteetit.git is the last version for merging.
Cool, I see.
Now I read something about gcc and it seem it's able to recognize and use comments, so __attribute__((fallthrough)) is unnecessary.
The default -Wimplicit-fallthrough setting is '3' and it means "parse comments".
So, do we really need this patch? ;-)
https://developers.redhat.com/blog/2017/03/10/wimplicit-fallthrough-in-gcc-7/
and man gcc man page:
-Wimplicit-fallthrough=0 disables the warning altogether.
-Wimplicit-fallthrough=1 matches .* regular expression, any comment is used as fallthrough comment. -Wimplicit-fallthrough=2 case insensitively matches .*falls?[ \t-]*thr(ough|u).* regular expression. -Wimplicit-fallthrough=3 case sensitively matches one of the following regular expressions:
-fallthrough
@fallthrough@
lint -fallthrough[ \t]*
[ \t.!]*(ELSE,? |INTENTIONAL(LY)? )?
FALL(S | |-)?THR(OUGH|U)[ \t.!]*(-[^\n\r]*)?
[ \t.!]*(Else,? |Intentional(ly)? )?
Fall((s | |-)[Tt]|t)hr(ough|u)[ \t.!]*(-[^\n\r]*)?
[ \t.!]*([Ee]lse,? |[Ii]ntentional(ly)? )?
fall(s | |-)?thr(ough|u)[ \t.!]*(-[^\n\r]*)?
-Wimplicit-fallthrough=4 case sensitively matches one of the following regular expressions:
-fallthrough
@fallthrough@
lint -fallthrough[ \t]*
[ \t]*FALLTHR(OUGH|U)[ \t]*
-Wimplicit-fallthrough=5 doesn’t recognize any comments as fallthrough comments, only attributes disable the warning.
sounds all we need is to add -Wimplicit-fallthrough=3 to ./configure.
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
Re: [PATCH 01/11] misc: fallthrough fixes
Quoted 70 lines · Karel Zak
Quoted 27 lines · Rüdiger Meier
Quoted 24 lines · Karel Zak
Quoted 8 lines · Rüdiger Meier
Quoted 6 lines
Quoted 4 lines
BTW just for cosmetics. Maybe we should rename
UL_FALLTHROUGHto__ul_fallthrough
like we have already__ul_calloc_size. IMO it would look more obvious to the reader.I don't have strong opinion about that, changed to one you proposed.
Thanks, let's see whether Karel likes this attribute at all ;)
Hmm...
I don't like "meta-programming" where language keywords are replaced by local macros, for example we have fallback (in
c.h) for all__attribute__rather than define local macro for all attributes.__attribute__((fallthrough))should be fine on non-__GNUC__ as in this case
__attribute__is empty macro (seec.h).Yes,
__ul_fallthroughseems better, and __attribute__((fallthrough)) would be the best :-)Quoted 8 lines
Quoted 2 lines
It's strange if clang will use a different syntax for the same things. IMHO it would be better to ignore clang for this attribute.
Yes, Sami's last version just ignores clang. Seems that the different syntax was for C++ only.
So branch 2017wk23 from [email protected]:kerolasa/lelux-utiliteetit.git is the last version for merging.
Cool, I see.
Now I read something about gcc and it seem it's able to recognize and use comments, so __attribute__((fallthrough)) is unnecessary.
The default -Wimplicit-fallthrough setting is '3' and it means "parse comments"
So, do we really need this patch? ;-)https://developers.redhat.com/blog/2017/03/10/wimplicit-fallthrough-in-gcc-7/and man gcc man page:
-Wimplicit-fallthrough=0 disables the warning altogether.
-Wimplicit-fallthrough=1 matches .* regular expression, any comment is used as fallthrough comment. -Wimplicit-fallthrough=2 case insensitively matches .*falls?[ \t-]*thr(ough|u).* regular expression. -Wimplicit-fallthrough=3 case sensitively matches one of the following regular expressions:
-fallthrough
@fallthrough@
lint -fallthrough[ \t]*
[ \t.!]*(ELSE,? |INTENTIONAL(LY)? )?
FALL(S | |-)?THR(OUGH|U)[ \t.!]*(-[^\n\r]*)?
[ \t.!]*(Else,? |Intentional(ly)? )?
Fall((s | |-)[Tt]|t)hr(ough|u)[ \t.!]*(-[^\n\r]*)?
[ \t.!]*([Ee]lse,? |[Ii]ntentional(ly)? )?
fall(s | |-)?thr(ough|u)[ \t.!]*(-[^\n\r]*)?
-Wimplicit-fallthrough=4 case sensitively matches one of the following regular expressions:
-fallthrough
@fallthrough@
lint -fallthrough[ \t]*
[ \t]*FALLTHR(OUGH|U)[ \t]*
-Wimplicit-fallthrough=5 doesn’t recognize any comments as fallthrough comments, only attributes disable the warning.
Quoted 1 line
sounds all we need is to add -Wimplicit-fallthrough=3 to ./configur
No, -Wimplicit-fallthrough=3 is what we have already now by default. Just tested. Without doing anything "/* fallthrough */" disables the warning. But Sami fixed also other comments and places without comments.
So we could simply use "/* fallthrough */" everythere.
Note, -Wimplicit-fallthrough=2 would be even more relaxed, e.g.
/* Fallthrough because bla. */ would work too.
cu,
Rudi
Karel Zak
maintainerRe: [PATCH 01/11] misc: fallthrough fixes
Quoted 6 lines · Rüdiger Meier
Quoted 1 line
sounds all we need is to add -Wimplicit-fallthrough=3 to ./configur
No, -Wimplicit-fallthrough=3 is what we have already now by default. Just tested. Without doing anything "/* fallthrough */" disables the warning. But Sami fixed also other comments and places without comments.
So we could simply use "/* fallthrough */" everythere.
Yes, that's what I mean (don't use the macro at all).
Sami, can you update the patch and replace __ul_fallthrough with /* fallthrough */ ?
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
Re: [PATCH 01/11] misc: fallthrough fixes
Quoted 6 lines · Karel Zak
Quoted 5 lines · Rüdiger Meier
Quoted 1 line
sounds all we need is to add -Wimplicit-fallthrough=3 to ./configur
No, -Wimplicit-fallthrough=3 is what we have already now by default. Just tested. Without doing anything "/* fallthrough */" disables the warning. But Sami fixed also other comments and places without comments.
Quoted 9 lines
Quoted 1 line
So we could simply use "/* fallthrough */" everythere.
Yes, that's what I mean (don't use the macro at all).
Sami, can you update the patch and replace
__ul_fallthroughwith /* fallthrough */ ?Karel
I've used one sed command on Sami's patch and submitted via github
https://github.com/karelzak/util-linux/pull/456
cu,
Rudi
Re: [PATCH 01/11] misc: fallthrough fixes
Quoted 11 lines · Rüdiger Meier
Quoted 10 lines · Karel Zak
Quoted 6 lines · Rüdiger Meier
Quoted 1 line
sounds all we need is to add -Wimplicit-fallthrough=3 to ./configur
No, -Wimplicit-fallthrough=3 is what we have already now by default. Just tested. Without doing anything "/* fallthrough */" disables the warning. But Sami fixed also other comments and places without comments.
So we could simply use "/* fallthrough */" everythere.
Yes, that's what I mean (don't use the macro at all).
Quoted 8 lines
Quoted 5 lines
Sami, can you update the patch and replace
__ul_fallthroughwith /* fallthrough */ ?Karel
I've used one sed command on Sami's patch and submitted via github
https://github.com/karelzak/util-linux/pull/456
Applied, thanks!
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
Re: [PATCH 01/11] misc: fallthrough fixes
Quoted 4 lines · Karel Zak
Quoted 2 lines
I've used one sed command on Sami's patch and submitted via github
https://github.com/karelzak/util-linux/pull/456Applied, thanks!
Thank you Rudi & Karel pushing this pull request over finishing line.
Signature · 2 lines
Sami Kerola http://www.iki.fi/kerolasa/
PATCH 2/11 line: do not print new line if nothing else was printed
In reply to Sami KerolaEarlier the following printed stray new line.
$ printf "" | ./line
--- text-utils/line.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
text-utils/line.c +4 -2
@@ -42,7 +42,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out)int main (int argc,char **argv) {wint_t c; -int opt; +int opt, print_nl =0 ;int status =EXIT_SUCCESS ;static const struct option longopts[] = {
@@ -77,8 +77,10 @@ int main(int argc, char **argv)if (c =='\n' )break ;putwchar (c); + print_nl =1 ; } -putwchar (L'\n' ); +if (print_nl) +putwchar (L'\n' );return status; }
Signature · 1 line
2.13.1
Re: [PATCH 02/11] line: do not print new line if nothing else was printed
Quoted 3 lines · Sami Kerola
Earlier the following printed stray new line.
$ printf "" | ./line
This breaks test "misc/line", see commit caad4ded
and
https://github.com/karelzak/util-linux/issues/236
Quoted 30 lines
Signed-off-by Sami Kerola <[email protected]>--- text-utils/line.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)text-utils/line.c +4
-2@@ -42,7 +42,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out) int main(int argc, char **argv) {wint_t c; -int opt; +int opt, print_nl =0 ;int status =EXIT_SUCCESS ;static const struct option longopts[] = {@@ -77,8 +77,10 @@ int main(int argc, char **argv)if (c =='\n' )break ;putwchar (c); + print_nl =1 ; } -putwchar (L'\n' ); +if (print_nl) +putwchar (L'\n' );return status; }
Re: [PATCH 02/11] line: do not print new line if nothing else was printed
Quoted 8 lines · Ruediger Meier
Quoted 3 lines · Sami Kerola
Earlier the following printed stray new line.
$ printf "" | ./lineThis breaks test "misc/line", see commit
caad4ded
and
https://github.com/karelzak/util-linux/issues/236
Thank you Rudi for noticing, the line(1) change is dropped from my remote branch.
Signature · 2 lines
Sami Kerola http://www.iki.fi/kerolasa/
PATCH 3/11 rename: notice when expression and replacement are the same string
In reply to Sami KerolaThe rename(1) can exit early when replace expression and replacement are identical string. It is also appropriate to change return value in this case to 'nothing was renamed'.
--- misc-utils/rename.c | 3 +++ 1 file changed, 3 insertions(+)
misc-utils/rename.c +3 -0
@@ -204,6 +204,9 @@ int main(int argc, char **argv) from = argv[0 ]; to = argv[1 ]; +if (!strcmp (from, to)) +return RENAME_EXIT_NOTHING ; +for (i =2 ; i < argc; i++) ret |=do_rename (from, to, argv[i], verbose, noact, nooverwrite);
Signature · 1 line
2.13.1
PATCH 4/11 uuidgen: slice up the usage text
In reply to Sami Kerola--- misc-utils/uuidgen.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
misc-utils/uuidgen.c +5 -5
@@ -28,11 +28,11 @@ static void __attribute__ ((__noreturn__)) usage(FILE * out)fputs (_ ("Create a new UUID value.\n" ), out);fputs (USAGE_OPTIONS , out); -fputs (_ (" -r, --random generate random-based uuid\n" -" -t, --time generate time-based uuid\n" -" -V, --version output version information and exit\n" -" -h, --help display this help and exit\n\n" ), out); - +fputs (_ (" -r, --random generate random-based uuid\n" ), out); +fputs (_ (" -t, --time generate time-based uuid\n" ), out); +fputs (USAGE_SEPARATOR , out); +fputs (USAGE_HELP , out); +fputs (USAGE_VERSION , out);fprintf (out,USAGE_MAN_TAIL ("uuidgen(1)" ));exit (out == stderr ?EXIT_FAILURE :EXIT_SUCCESS ); }
Signature · 1 line
2.13.1
PATCH 5/11 uuidgen: add --date option to display time when uuid was generated
In reply to Sami KerolaThe uuidgen has always had option to use time as a uuid value. To common users these timestamps have been difficult to convert to readable format, so add an option to do that.
--- bash-completion/uuidgen | 5 ++++- misc-utils/Makemodule.am | 2 +- misc-utils/uuidgen.1 | 8 ++++++++ misc-utils/uuidgen.c | 41 +++++++++++++++++++++++++++++++++++++++-- tests/expected/uuid/uuidgen | 6 ++++++ tests/ts/uuid/uuidgen | 10 ++++++++++ 6 files changed, 68 insertions(+), 4 deletions(-)
bash-completion/uuidgen +4 -1
@@ -8,10 +8,13 @@ _uuidgen_module() '-h'|'--help'|'-V'|'--version') return 0 ;; + '--date') + COMPREPLY=( $(compgen -W "uuid" -- $cur) ) + ;; esac case $cur in -*) - OPTS="--random --time --version --help" + OPTS="--random --time --date --version --help" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;;
misc-utils/Makemodule.am +1 -1
@@ -84,7 +84,7 @@ if BUILD_UUIDGEN usrbin_exec_PROGRAMS += uuidgen dist_man_MANS += misc-utils/uuidgen.1 uuidgen_SOURCES = misc-utils/uuidgen.c -uuidgen_LDADD = $(LDADD) libuuid.la +uuidgen_LDADD = $(LDADD) libuuid.la libcommon.la uuidgen_CFLAGS = $(AM_CFLAGS) -I$(ul_libuuid_incdir) endif
misc-utils/uuidgen.1 +8 -0
@@ -42,6 +42,14 @@ quality random number generator, such as Generate a time-based UUID. This method creates a UUID based on the system clock plus the system's ethernet hardware address, if present. .TP +.BI "\-\-date " uuid +Display when a time-based UUID was generated. If there are additional +command-line arguments they are printed as well. +.PP +Notice that there is no way to know by looking an UUID if it is time or +random based. Both types are converted, and random-based UUIDs tend to have +values mostly in future, but sometimes in past. +.TP .BR \-h , " \-\-help" Display help text and exit. .TP
misc-utils/uuidgen.c +39 -2
81 lines not on this page · raw message
tests/expected/uuid/uuidgen +6 -0
@@ -6,3 +6,9 @@ option: --random return values: 0 and 0 option: --time return values: 0 and 0 +test --date +2017-05-21 17:25:32,471528+0000 +2017-05-21 17:50:52,171166+0000 +invalid uuid: 080fc42c-3e4e-11e7-8ba8-00037f50000 +invalid uuid: 080fc42c-3e4e-11e7-8ba8-00037f50000g +return value: 1
tests/ts/uuid/uuidgen +10 -0
@@ -40,6 +40,16 @@ test_flag -t test_flag --random test_flag --time +export TZ=GMT +echo "test --date" >> $TS_OUTPUT +$TS_CMD_UUIDGEN --date \ + 7e400110-3e4a-11e7-8af1-00037f500001 \ + 080fc42c-3e4e-11e7-8ba8-00037f500001 \ + 080fc42c-3e4e-11e7-8ba8-00037f50000 \ + 080fc42c-3e4e-11e7-8ba8-00037f50000g \ + >> "$TS_OUTPUT" 2>&1 +echo "return value: $?" >> $TS_OUTPUT + rm -f "$OUTPUT_FILE" ts_finalize
Signature · 1 line
2.13.1
Karel Zak
maintainerRe: [PATCH 05/11] uuidgen: add --date option to display time when uuid was generated
Quoted 3 lines · Sami Kerola
The uuidgen has always had option to use time as a uuid value. To common users these timestamps have been difficult to convert to readable format, so add an option to do that.
The name of the tool is uuidgen and at first glance it seems like --date is a way how to use a different time than the current ;-)
Maybe it would be better to create a small independent tool uuidparse and print all available details about UUID (variant, type and time).
$ uuidparse 7e400110-3e4a-11e7-8af1-00037f500001 variant: DCE type: time time: 2017-05-21 17:25:32,471528+0000
$ uuidparse --time 2017-05-21 17:25:32,471528+0000
It would be also nice to accept more than one UUID on command line/stdin.
or so... Comments?
See libuuid/src/uuid_time.c where is test program.
misc-utils/uuidgen.c static void __attribute__ ((__noreturn__)) usage(FILE * out) · line 49
Quoted 8 lines
misc-utils/uuidgen.c +8
-0+static int print_uuid_date (char *date) +{ +uuid_t uuid; +struct timeval tv; +char buf[ISO_8601_BUFSIZ ]; + +if (uuid_parse (date, uuid)) { +printf (_ ("invalid uuid: %s\n" ), date);
"failed to parse UUID" sounds better
Review
Quoted 2 lines
(quoted diff) +2
-0+ return 1; + }
Maybe you want to check UUID type and variant, only DCE time is supported.
I think separated pull request would be better ;-)
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
Re: [PATCH 05/11] uuidgen: add --date option to display time when uuid was generated
Quoted 36 lines · Karel Zak
Quoted 3 lines · Sami Kerola
The uuidgen has always had option to use time as a uuid value. To common users these timestamps have been difficult to convert to readable format, so add an option to do that.
The name of the tool is uuidgen and at first glance it seems like --date is a way how to use a different time than the current ;-)
Maybe it would be better to create a small independent tool uuidparse and print all available details about UUID (variant, type and time).
$ uuidparse 7e400110-3e4a-11e7-8af1-00037f500001 variant: DCE type: time time: 2017-05-21 17:25:32,471528+0000$ uuidparse --time 2017-05-21 17:25:32,471528+0000It would be also nice to accept more than one UUID on command line/stdin.
or so... Comments?
See
libuuid/src/uuid_time.cwhere is test program.misc-utils/uuidgen.c static void __attribute__ ((__noreturn__)) usage(FILE * out) · line 49
Quoted 8 lines
misc-utils/uuidgen.c +8
-0+static int print_uuid_date (char *date) +{ +uuid_t uuid; +struct timeval tv; +char buf[ISO_8601_BUFSIZ ]; + +if (uuid_parse (date, uuid)) { +printf (_ ("invalid uuid: %s\n" ), date);"failed to parse UUID" sounds better
Quoted 7 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ return 1; + }Maybe you want to check UUID type and variant, only DCE time is supported.
I think separated pull request would be better ;-)
I thought it would be better avoid adding small binaries, but no problems I can do that and ensure all the other feedback is incorporated to that utility as well.
Signature · 2 lines
Sami Kerola http://www.iki.fi/kerolasa/
PATCH 6/11 isosize: avoid reading more data than what is needed
In reply to Sami KerolaIn same go fix error reporting when input file is not long enough.
$ touch empty $ isosize empty isosize: empty: might not be an ISO filesystem isosize: read error on empty: Success
--- disk-utils/isosize.c | 57 +++++++++------------------------------------------- 1 file changed, 10 insertions(+), 47 deletions(-)
disk-utils/isosize.c +10 -47
@@ -30,8 +30,6 @@#include "strutils.h" #include "closestream.h" -#define ISODCL (from, to) (to - from + 1) -static int is_iso (int fd) {char label[8 ];
@@ -88,62 +86,27 @@ static int isonum_733(unsigned char *p, int xflag)return (le); } -struct iso_primary_descriptor -{ -unsigned char type [ISODCL (1 ,1 )];/* 711 */ -unsigned char id [ISODCL (2 ,6 )]; -unsigned char version [ISODCL (7 ,7 )];/* 711 */ -unsigned char unused1 [ISODCL (8 ,8 )]; -unsigned char system_id [ISODCL (9 ,40 )];/* auchars */ -unsigned char volume_id [ISODCL (41 ,72 )];/* duchars */ -unsigned char unused2 [ISODCL (73 ,80 )]; -unsigned char volume_space_size [ISODCL (81 ,88 )];/* 733 */ -unsigned char unused3 [ISODCL (89 ,120 )]; -unsigned char volume_set_size [ISODCL (121 ,124 )];/* 723 */ -unsigned char volume_sequence_number [ISODCL (125 ,128 )];/* 723 */ -unsigned char logical_block_size [ISODCL (129 ,132 )];/* 723 */ -unsigned char path_table_size [ISODCL (133 ,140 )];/* 733 */ -unsigned char type_l_path_table [ISODCL (141 ,144 )];/* 731 */ -unsigned char opt_type_l_path_table [ISODCL (145 ,148 )];/* 731 */ -unsigned char type_m_path_table [ISODCL (149 ,152 )];/* 732 */ -unsigned char opt_type_m_path_table [ISODCL (153 ,156 )];/* 732 */ -unsigned char root_directory_record [ISODCL (157 ,190 )];/* 9.1 */ -unsigned char volume_set_id [ISODCL (191 ,318 )];/* duchars */ -unsigned char publisher_id [ISODCL (319 ,446 )];/* achars */ -unsigned char preparer_id [ISODCL (447 ,574 )];/* achars */ -unsigned char application_id [ISODCL (575 ,702 )];/* achars */ -unsigned char copyright_file_id [ISODCL (703 ,739 )];/* 7.5 dchars */ -unsigned char abstract_file_id [ISODCL (740 ,776 )];/* 7.5 dchars */ -unsigned char bibliographic_file_id [ISODCL (777 ,813 )];/* 7.5 dchars */ -unsigned char creation_date [ISODCL (814 ,830 )];/* 8.4.26.1 */ -unsigned char modification_date [ISODCL (831 ,847 )];/* 8.4.26.1 */ -unsigned char expiration_date [ISODCL (848 ,864 )];/* 8.4.26.1 */ -unsigned char effective_date [ISODCL (865 ,881 )];/* 8.4.26.1 */ -unsigned char file_structure_version [ISODCL (882 ,882 )];/* 711 */ -unsigned char unused4 [ISODCL (883 ,883 )]; -unsigned char application_data [ISODCL (884 ,1395 )]; -unsigned char unused5 [ISODCL (1396 ,2048 )]; -}; -static void isosize (int argc,char *filenamep,int xflag,long divisor) {int fd, nsecs, ssize; -struct iso_primary_descriptor ipd; +unsigned char volume_space_size[8 ]; +unsigned char logical_block_size[4 ];if ((fd =open (filenamep,O_RDONLY )) <0 )err (EXIT_FAILURE ,_ ("cannot open %s" ), filenamep);if (is_iso (fd))warnx (_ ("%s: might not be an ISO filesystem" ), filenamep); -if (lseek (fd,16 <<11 ,0 ) == (off_t) -1 ) -err (EXIT_FAILURE ,_ ("seek error on %s" ), filenamep); - -if (read (fd, &ipd,sizeof (ipd)) <=0 ) -err (EXIT_FAILURE ,_ ("read error on %s" ), filenamep); +if (pread (fd, volume_space_size,sizeof (volume_space_size),0x8050 ) <=0 || +pread (fd, logical_block_size,sizeof (logical_block_size),0x8080 ) <=0 ) { +if (errno) +err (EXIT_FAILURE ,_ ("read error on %s" ), filenamep); +errx (EXIT_FAILURE ,_ ("read error on %s" ), filenamep); + } - nsecs =isonum_733 (ipd.volume_space_size, xflag); + nsecs =isonum_733 (volume_space_size, xflag);/* isonum_723 returns nowadays always 2048 */ - ssize =isonum_723 (ipd.logical_block_size, xflag); + ssize =isonum_723 (logical_block_size, xflag);if (1 < argc)printf ("%s: " , filenamep);
Signature · 1 line
2.13.1
PATCH 7/11 misc: fix reassigned values before old ones has been used [cppcheck]
In reply to Sami Kerola--- disk-utils/cfdisk.c | 2 +- libblkid/src/devno.c | 2 +- libblkid/src/probe.c | 2 +- libfdisk/src/gpt.c | 2 +- libfdisk/src/script.c | 2 +- libmount/src/btrfs.c | 2 +- libmount/src/cache.c | 6 +++--- libmount/src/context.c | 2 +- libmount/src/context_umount.c | 2 +- libmount/src/optstr.c | 2 +- libmount/src/tab_diff.c | 4 ++-- libmount/src/tab_update.c | 2 +- libsmartcols/src/column.c | 2 +- misc-utils/findmnt-verify.c | 2 +- misc-utils/findmnt.c | 8 ++++---- sys-utils/losetup.c | 2 +- sys-utils/swapon.c | 2 +- 17 files changed, 23 insertions(+), 23 deletions(-)
disk-utils/cfdisk.c +1 -1
@@ -323,7 +323,7 @@ static char *table_to_string(struct cfdisk *cf, struct fdisk_table *tb) {struct fdisk_partition *pa;struct fdisk_label *lb; -struct fdisk_iter *itr =NULL ; +struct fdisk_iter *itr;struct libscols_table *table =NULL ;struct libscols_iter *s_itr =NULL ;char *res =NULL ;
libblkid/src/devno.c +1 -1
@@ -225,7 +225,7 @@ static char *scandev_devno_to_devpath(dev_t devno)*/ char *blkid_devno_to_devname (dev_t devno) { -char *path =NULL ; +char *path;char buf[PATH_MAX ]; path =sysfs_devno_to_devpath (devno, buf,sizeof (buf));
libblkid/src/probe.c +1 -1
@@ -206,7 +206,7 @@ blkid_probe blkid_clone_probe(blkid_probe parent)*/ blkid_probe blkid_new_probe_from_filename (const char *filename) { -int fd =-1 ; +int fd;blkid_probe pr =NULL ; fd =open (filename,O_RDONLY |O_CLOEXEC );
libfdisk/src/gpt.c +1 -1
@@ -1913,7 +1913,7 @@ fail:static int gpt_write_pmbr (struct fdisk_context *cxt) {off_t offset; -struct gpt_legacy_mbr *pmbr =NULL ; +struct gpt_legacy_mbr *pmbr;assert (cxt);assert (cxt->firstsector);
libfdisk/src/script.c +1 -1
@@ -1528,7 +1528,7 @@ static int test_apply(struct fdisk_test *ts, int argc, char *argv[]) {char *devname = argv[1 ], *scriptname = argv[2 ];struct fdisk_context *cxt; -struct fdisk_script *dp =NULL ; +struct fdisk_script *dp;struct fdisk_table *tb =NULL ;struct fdisk_iter *itr =NULL ;struct fdisk_partition *pa =NULL ;
libmount/src/btrfs.c +1 -1
@@ -105,7 +105,7 @@ uint64_t btrfs_get_default_subvol_id(const char *path) {int iocret;int fd; -DIR *dirstream =NULL ; +DIR *dirstream;struct btrfs_ioctl_search_args args;struct btrfs_ioctl_search_key *sk = &args.key;struct btrfs_ioctl_search_header *sh;
libmount/src/cache.c +3 -3
@@ -489,9 +489,9 @@ char *mnt_get_fstype(const char *devname, int *ambi, struct libmnt_cache *cache)static char *canonicalize_path_and_cache (const char *path,struct libmnt_cache *cache) { -char *p =NULL ; -char *key =NULL ; -char *value =NULL ; +char *p; +char *key; +char *value;DBG (CACHE ,ul_debugobj (cache,"canonicalize path %s" , path)); p =canonicalize_path (path);
libmount/src/context.c +1 -1
@@ -1965,7 +1965,7 @@ static int apply_table(struct libmnt_context *cxt, struct libmnt_table *tb, int direction) {struct libmnt_fs *fs =NULL ; -const char *src =NULL , *tgt =NULL ; +const char *src, *tgt;int rc;assert (cxt);
libmount/src/context_umount.c +1 -1
@@ -478,7 +478,7 @@ static int evaluate_permissions(struct libmnt_context *cxt)*/ if (u_flags & (MNT_MS_USER |MNT_MS_OWNER |MNT_MS_GROUP )) { -char *curr_user =NULL ; +char *curr_user;char *mtab_user =NULL ;size_t sz;
libmount/src/optstr.c +1 -1
@@ -382,7 +382,7 @@ insert_value(char **str, char *pos, const char *substr, char **next)size_t strsz =strlen (*str);size_t possz =strlen (pos);size_t posoff; -char *p =NULL ; +char *p;int sep;/* is it necessary to prepend '=' before the substring ? */
libmount/src/tab_diff.c +2 -2
@@ -305,8 +305,8 @@ done:static int test_diff (struct libmnt_test *ts,int argc,char *argv[]) { -struct libmnt_table *tb_old =NULL , *tb_new =NULL ; -struct libmnt_tabdiff *diff =NULL ; +struct libmnt_table *tb_old, *tb_new; +struct libmnt_tabdiff *diff;struct libmnt_iter *itr;struct libmnt_fs *old, *new;int rc =-1 , change;
libmount/src/tab_update.c +1 -1
@@ -291,7 +291,7 @@ static int utab_new_entry(struct libmnt_update *upd, struct libmnt_fs *fs, unsigned long mountflags) {int rc =0 ; -const char *o =NULL , *a =NULL ; +const char *o, *a;char *u =NULL ;assert (fs);
libsmartcols/src/column.c +1 -1
@@ -293,7 +293,7 @@ size_t scols_wrapnl_chunksize(const struct libscols_column *cl __attribute__((unsize_t sum =0 ;while (data && *data) { -const char *p = data; +const char *p;size_t sz; p =strchr (data,'\n' );
misc-utils/findmnt-verify.c +1 -1
@@ -472,7 +472,7 @@ static int verify_filesystem(struct verify_context *vfy)int verify_table (struct libmnt_table *tb) {struct verify_context vfy = { .nerrors =0 }; -struct libmnt_iter *itr =NULL ; +struct libmnt_iter *itr;int rc =0 ;/* overall return code (alloc errors, etc.) */ int check_order =is_listall_mode ();static int has_read_fs =0 ;
misc-utils/findmnt.c +4 -4
@@ -873,7 +873,7 @@ static void cache_set_targets(struct libmnt_cache *tmp)static int tab_is_tree (struct libmnt_table *tb) {struct libmnt_fs *fs =NULL ; -struct libmnt_iter *itr =NULL ; +struct libmnt_iter *itr;int rc =0 ; itr =mnt_new_iter (MNT_ITER_BACKWARD );
@@ -892,7 +892,7 @@ static int tab_is_tree(struct libmnt_table *tb)static int tab_is_kernel (struct libmnt_table *tb) {struct libmnt_fs *fs =NULL ; -struct libmnt_iter *itr =NULL ; +struct libmnt_iter *itr; itr =mnt_new_iter (MNT_ITER_BACKWARD );if (!itr)
@@ -1008,7 +1008,7 @@ again:static int add_matching_lines (struct libmnt_table *tb,struct libscols_table *table,int direction) { -struct libmnt_iter *itr =NULL ; +struct libmnt_iter *itr;struct libmnt_fs *fs;int nlines =0 , rc =-1 ;
@@ -1068,7 +1068,7 @@ static int poll_table(struct libmnt_table *tb, const char *tabfile,FILE *f =NULL ;int rc =-1 ;struct libmnt_iter *itr =NULL ; -struct libmnt_table *tb_new =NULL ; +struct libmnt_table *tb_new;struct libmnt_tabdiff *diff =NULL ;struct pollfd fds[1 ];
sys-utils/losetup.c +1 -1
@@ -113,7 +113,7 @@ static int printf_loopdev(struct loopdev_cxt *lc)uint64_t x;dev_t dev =0 ;ino_t ino =0 ; -char *fname =NULL ; +char *fname;uint32_t type; fname =loopcxt_get_backing_file (lc);
sys-utils/swapon.c +1 -1
@@ -501,7 +501,7 @@ static void swap_get_info(struct swap_device *dev, const char *hdr)static int swapon_checks (const struct swapon_ctl *ctl,struct swap_device *dev) {struct stat st; -int fd =-1 , sig; +int fd, sig;char *hdr =NULL ;unsigned long long devsize =0 ;int permMask;
Signature · 1 line
2.13.1
PATCH 8/11 losetup: add missing initializer [clang]
In reply to Sami KerolaFIXME: I am not entirely sure if rc should be initialized to 1 or 0.
sys-utils/losetup.c:290:12: warning: variable 'rc' is used uninitialized
whenever 'if' condition is false [-Wsometimes-uninitialized]sys-utils/losetup.c:293:7: note: uninitialized use occurs here sys-utils/losetup.c:290:8: note: remove the 'if' if its condition is always true sys-utils/losetup.c:228:9: note: initialize the variable 'rc' to silence
this warning
--- sys-utils/losetup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sys-utils/losetup.c +1 -1
@@ -225,7 +225,7 @@ static int set_scols_data(struct loopdev_cxt *lc, struct libscols_line *ln)const char *p =NULL ;/* external data */ char *np =NULL ;/* allocated here */ uint64_t x =0 ; -int rc; +int rc =0 ;switch (get_column_id (i)) {case COL_NAME :
Signature · 1 line
2.13.1
PATCH 9/11 misc: remove stray semicolons
In reply to Sami Kerola--- lib/mbsalign.c | 2 +- libblkid/src/superblocks/adaptec_raid.c | 2 +- libmount/src/btrfs.c | 4 ++-- libmount/src/context_mount.c | 2 +- libmount/src/context_umount.c | 2 +- libsmartcols/src/column.c | 2 +- misc-utils/test_uuidd.c | 2 +- sys-utils/unshare.c | 2 +- term-utils/wall.c | 2 +- text-utils/column.c | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-)
lib/mbsalign.c +1 -1
@@ -206,7 +206,7 @@ size_t mbs_safe_encode_size(size_t bytes)char *mbs_safe_encode (const char *s,size_t *width) {size_t sz = s ?strlen (s) :0 ; -char *buf, *ret =NULL ;; +char *buf, *ret =NULL ;if (!sz)return NULL ;
libblkid/src/superblocks/adaptec_raid.c +1 -1
@@ -91,7 +91,7 @@ static int probe_adraid(blkid_probe pr, off, sizeof(struct adaptec_metadata));if (!ad) -return errno ? -errno :BLKID_PROBE_NONE ;; +return errno ? -errno :BLKID_PROBE_NONE ;if (ad->smagic !=be32_to_cpu (AD_SIGNATURE ))return BLKID_PROBE_NONE ;
libmount/src/btrfs.c +2 -2
@@ -75,9 +75,9 @@ static inline void btrfs_set_##name(type *s, uint##bits##_t val) \/* struct btrfs_disk_key */ BTRFS_SETGET_STACK_FUNCS(disk_key_objectid, struct btrfs_disk_key, - objectid,64 ); + objectid, 64) -BTRFS_SETGET_STACK_FUNCS(stack_dir_name_len, struct btrfs_dir_item, name_len, 16); +BTRFS_SETGET_STACK_FUNCS(stack_dir_name_len, struct btrfs_dir_item, name_len, 16)/* Red Black Trees
libmount/src/context_mount.c +1 -1
@@ -1042,7 +1042,7 @@ int mnt_context_finalize_mount(struct libmnt_context *cxt) rc =mnt_context_prepare_update (cxt);if (!rc) - rc =mnt_context_update_tabs (cxt);; + rc =mnt_context_update_tabs (cxt);return rc; }
libmount/src/context_umount.c +1 -1
@@ -889,7 +889,7 @@ int mnt_context_finalize_umount(struct libmnt_context *cxt) rc =mnt_context_prepare_update (cxt);if (!rc) - rc =mnt_context_update_tabs (cxt);; + rc =mnt_context_update_tabs (cxt);return rc; }
libsmartcols/src/column.c +1 -1
@@ -304,7 +304,7 @@ size_t scols_wrapnl_chunksize(const struct libscols_column *cl __attribute__((un sz =mbs_safe_width (data); sum =max (sum, sz); - data = p;; + data = p; }return sum;
misc-utils/test_uuidd.c +1 -1
@@ -143,7 +143,7 @@ static void *create_uuids(thread_t *th)object_uuid_create (obj); obj->tid = th->tid; obj->pid = th->proc->pid; - obj->idx = th->index + i;; + obj->idx = th->index + i; }return NULL ; }
sys-utils/unshare.c +1 -1
@@ -308,7 +308,7 @@ int main(int argc, char *argv[])int status;unsigned long propagation =UNSHARE_PROPAGATION_DEFAULT ;uid_t real_euid =geteuid (); -gid_t real_egid =getegid ();; +gid_t real_egid =getegid ();setlocale (LC_ALL ,"" );bindtextdomain (PACKAGE ,LOCALEDIR );
term-utils/wall.c +1 -1
@@ -303,7 +303,7 @@ static void buf_printf(struct buffer *bs, const char *fmt, ...)buf_enlarge (bs, (size_t )rc +1 ); limit = bs->sz - bs->used;va_start (ap, fmt); - rc =vsnprintf (bs->data + bs->used, limit, fmt, ap);; + rc =vsnprintf (bs->data + bs->used, limit, fmt, ap);va_end (ap); }
text-utils/column.c +1 -1
@@ -482,7 +482,7 @@ static void columnate_fillrows(struct column_control *ctl) ctl->maxlength = (ctl->maxlength +TABCHAR_CELLS ) & ~(TABCHAR_CELLS -1 ); numcols = ctl->termwidth / ctl->maxlength; endcol = ctl->maxlength; -for (chcnt = col =0 , lp = ctl->ents;; ++lp) { +for (chcnt = col =0 , lp = ctl->ents;/* nothing */ ; ++lp) {fputws (*lp, stdout); chcnt +=width (*lp);if (!--ctl->nents)
Signature · 1 line
2.13.1
PATCH 10/11 lib: simplify cpuset if clauses that return
In reply to Sami KerolaThere is no need for 'else' when 'if' will return. In same go move call of tolower() to last possible moment in char_to_val(), a lot of time hex values should hit 0-9 range, and it can be omitted.
--- lib/cpuset.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
lib/cpuset.c +5 -7
@@ -29,23 +29,21 @@ static inline int val_to_char(int v) {if (v >=0 && v <10 )return '0' + v; -else if (v >=10 && v <16 ) +if (v >=10 && v <16 )return ('a' -10 ) + v; -else -return -1 ; +return -1 ; }static inline int char_to_val (int c) {int cl; - cl =tolower (c);if (c >='0' && c <='9' )return c -'0' ; -else if (cl >='a' && cl <='f' ) + cl =tolower (c); +if (cl >='a' && cl <='f' )return cl + (10 -'a' ); -else -return -1 ; +return -1 ; }static const char *nexttoken (const char *q,int sep)
Signature · 1 line
2.13.1
PATCH 11/11 lib: remove _RLD_ from forbid environment variable list
In reply to Sami KerolaThe RLD environment variables are related to runtime linker vulnerability in TELNET on systems running Silicon Graphics IRIX. It is extremely unlikely current util-linux would be compiled on such system.
Reference: http://www.cert.org/historical/advisories/CA-1995-14.cfm
Reference: http://signatures.juniper.net/documentation/signatures/TELNET%3AEXPLOIT%3ASGI-RLD.html
Refefence: http://www.polarhome.com/service/man/?qf=rld&tf=2&of=IRIX&sf=1
--- lib/env.c | 1 - 1 file changed, 1 deletion(-)
lib/env.c +0 -1
@@ -26,7 +26,6 @@ extern char **environ;#endif static char *const forbid[] = { -"_RLD_=" ,"BASH_ENV=" ,/* GNU creeping featurism strikes again... */ "ENV=" ,"HOME=" ,
Signature · 1 line
2.13.1
Quoted 1 line · Sami Kerola
misc: fallthrough fixes
Fixed by patches from Rudi.
Quoted 3 lines
line: do not print new line if nothing else was printed
rename: notice when expression and replacement are the same string
uuidgen: slice up the usage text
Applied.
Quoted 1 line
uuidgen: add --date option to display time when uuid was generated
Not applied, "uuidparse" suggested.
Quoted 6 lines
isosize: avoid reading more data than what is needed
misc: fix reassigned values before old ones has been used [cppcheck]
losetup: add missing initializer [clang]
misc: remove stray semicolons
lib: simplify cpuset if clauses that return
lib: remove _RLD_ from forbid environment variable list
Applied, thanks.
Please, don't add new features to cleanup pull requests, and always use separate pull request for stuff you're not sure with it :)
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com