btrfs-progs/common
Qu Wenruo 2eb48d8c81 btrfs-progs: fix seemly wrong format overflow warning
[WARNING]
When compiling btrfs-progs, the following warning pops up:
  In file included from /usr/include/stdio.h:867,
                   from ./kerncompat.h:22,
                   from common/fsfeatures.c:17:
  In function 'printf',
      inlined from 'process_features' at common/fsfeatures.c:192:4,
      inlined from 'btrfs_process_runtime_features' at common/fsfeatures.c:205:2:
  /usr/include/bits/stdio2.h:107:10: warning: '%s' directive argument is null [-Wformat-overflow=]
    107 |   return __printf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ());
        |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This only occur with default make parameters. If compiling with D=1, the
warning just disappears.

The involved tool chain is:
- GCC 10.1.0

[CAUSE]
The offending code is:
  static void process_features(u64 flags, enum feature_source source)
  {
  ...
		if (flags & feat->flag) {
			printf("Turning ON incompat feature '%s': %s\n",
				feat->name, feat->desc);
		}
  ...
  }

Currently, there is no runtime/fs feature without a name nor
description.  So we shouldn't hit a feature with NULL as name nor
description.

This looks like a bug in GCC though.

[WORKAROUND]
However can workaround it by doing an explicit check on feat->name and
feat->desc to teach GCC not to do a wrong warning.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2020-06-29 17:45:39 +02:00
..
box.h btrfs-progs: build most common tools into one binary (busybox style) 2019-07-04 15:30:40 +02:00
defs.h btrfs-progs: move common-defs to common/ 2020-03-31 18:37:35 +02:00
device-scan.c btrfs-progs: refactor btrfs_scan_devices() to accept verbose argument 2020-06-12 19:31:58 +02:00
device-scan.h btrfs-progs: refactor btrfs_scan_devices() to accept verbose argument 2020-06-12 19:31:58 +02:00
device-utils.c btrfs-progs: utils: split device handling functions to own file 2019-07-04 02:06:34 +02:00
device-utils.h btrfs-progs: utils: split device handling functions to own file 2019-07-04 02:06:34 +02:00
format-output.c btrfs-progs: move common-defs to common/ 2020-03-31 18:37:35 +02:00
format-output.h btrfs-progs: lots of typo fixes (codespell) 2020-03-31 18:37:38 +02:00
fsfeatures.c btrfs-progs: fix seemly wrong format overflow warning 2020-06-29 17:45:39 +02:00
fsfeatures.h btrfs-progs: mkfs: introduce quota runtime feature 2020-05-28 19:59:56 +02:00
help.c btrfs-progs: split global help HELPINFO_INSERT_GLOBALS 2020-06-12 19:30:36 +02:00
help.h btrfs-progs: add global verbose and quiet options and helper functions 2020-06-12 19:30:43 +02:00
internal.h btrfs-progs: move internal.h to common/ 2019-07-03 20:49:03 +02:00
messages.c btrfs-progs: add global verbose and quiet options and helper functions 2020-06-12 19:30:43 +02:00
messages.h btrfs-progs: add separate verbosity level for on-by-default messages 2020-06-12 19:32:29 +02:00
path-utils.c btrfs-progs: path-utils: rename test_isdir 2019-07-04 02:06:33 +02:00
path-utils.h btrfs-progs: path-utils: rename test_isdir 2019-07-04 02:06:33 +02:00
rbtree-utils.c btrfs-progs: move rbtree-utils.[ch] to common/ 2019-07-03 20:49:04 +02:00
rbtree-utils.h btrfs-progs: move rbtree-utils.[ch] to common/ 2019-07-03 20:49:04 +02:00
string-table.c btrfs-progs: move string-table.[ch] to common/ 2019-07-03 20:49:03 +02:00
string-table.h btrfs-progs: move string-table.[ch] to common/ 2019-07-03 20:49:03 +02:00
task-utils.c btrfs-progs: move task-utils.[ch] to common/ 2019-07-03 20:49:03 +02:00
task-utils.h btrfs-progs: move task-utils.[ch] to common/ 2019-07-03 20:49:03 +02:00
utils.c btrfs-progs: refactor btrfs_scan_devices() to accept verbose argument 2020-06-12 19:31:58 +02:00
utils.h btrfs-progs: add global verbose and quiet options and helper functions 2020-06-12 19:30:43 +02:00