btrfs-progs-6.8-1.fc41
List of Defects
Error: SHELLCHECK_WARNING: [#def1]
/usr/sbin/fsck.btrfs:25:2: warning[SC2220]: Invalid flags are not handled. Add a *) case.
# 23| while getopts ":aApy" c
# 24| do
# 25|-> case $c in
# 26| a|A|p|y) AUTO=true;;
# 27| esac
Error: SHELLCHECK_WARNING (CWE-569): [#def2]
/usr/sbin/fsck.btrfs:30:12: warning[SC1083]: This { is literal. Check expression (missing ;/\n?) or quote it.
# 28| done
# 29| shift $(($OPTIND - 1))
# 30|-> eval DEV=\${$#}
# 31| if [ ! -e $DEV ]; then
# 32| echo "$0: $DEV does not exist"
Error: SHELLCHECK_WARNING (CWE-569): [#def3]
/usr/sbin/fsck.btrfs:30:15: warning[SC1083]: This } is literal. Check expression (missing ;/\n?) or quote it.
# 28| done
# 29| shift $(($OPTIND - 1))
# 30|-> eval DEV=\${$#}
# 31| if [ ! -e $DEV ]; then
# 32| echo "$0: $DEV does not exist"
Error: GCC_ANALYZER_WARNING (CWE-401): [#def4]
btrfs-progs-v6.8/btrfs-corrupt-block.c: scope_hint: In function ‘debug_corrupt_sector’
btrfs-progs-v6.8/btrfs-corrupt-block.c:86:20: warning[-Wanalyzer-malloc-leak]: leak of ‘buf’
# 84|
# 85| num_copies = btrfs_num_copies(root->fs_info, logical, sectorsize);
# 86|-> if (num_copies == 1)
# 87| break;
# 88|
Error: CLANG_WARNING: [#def5]
btrfs-progs-v6.8/btrfs-corrupt-block.c:221:4: warning[deadcode.DeadStores]: Value stored to 'ret' is never read
# 219| break;
# 220| path->slots[0]--;
# 221|-> ret = 0;
# 222| }
# 223| leaf = path->nodes[0];
Error: CLANG_WARNING: [#def6]
btrfs-progs-v6.8/btrfs-corrupt-block.c:887:2: warning[deadcode.DeadStores]: Value stored to 'ret' is never read
# 885| }
# 886|
# 887|-> ret = 0;
# 888| switch (corrupt_field) {
# 889| case BTRFS_METADATA_BLOCK_GENERATION:
Error: CLANG_WARNING: [#def7]
btrfs-progs-v6.8/btrfs-corrupt-block.c:955:3: warning[deadcode.DeadStores]: Value stored to 'eb' is never read
# 953| return ret;
# 954| }
# 955|-> eb = path->nodes[level];
# 956| shift_items(root, path->nodes[level]);
# 957| btrfs_mark_buffer_dirty(path->nodes[level]);
Error: CLANG_WARNING: [#def8]
btrfs-progs-v6.8/btrfs-corrupt-block.c:1203:3: warning[deadcode.DeadStores]: Value stored to 'slot' is never read
# 1201| /* corrupt/del dev_item first */
# 1202| while (!btrfs_previous_item(root, path, 0, BTRFS_DEV_ITEM_KEY)) {
# 1203|-> slot = path->slots[0];
# 1204| leaf = path->nodes[0];
# 1205| del = rand_range(3);
Error: CLANG_WARNING: [#def9]
btrfs-progs-v6.8/btrfs-corrupt-block.c:1204:3: warning[deadcode.DeadStores]: Value stored to 'leaf' is never read
# 1202| while (!btrfs_previous_item(root, path, 0, BTRFS_DEV_ITEM_KEY)) {
# 1203| slot = path->slots[0];
# 1204|-> leaf = path->nodes[0];
# 1205| del = rand_range(3);
# 1206| /* Never delete the first item to keep the leaf structure */
Error: COMPILER_WARNING: [#def10]
btrfs-progs-v6.8/btrfs-corrupt-block.c: scope_hint: In function ‘main’
btrfs-progs-v6.8/btrfs-corrupt-block.c:1400:33: warning[-Wstringop-truncation]: ‘strncpy’ specified bound 80 equals destination size
# 1400 | strncpy(field, optarg, FIELD_BUF_LEN);
# | ^
# 1398| break;
# 1399| case 'f':
# 1400|-> strncpy(field, optarg, FIELD_BUF_LEN);
# 1401| break;
# 1402| case 'x':
Error: CLANG_WARNING: [#def11]
btrfs-progs-v6.8/btrfs-find-root.c:406:10: warning[core.NullDereference]: Access to field 'start' results in a dereference of an undefined pointer value (loaded from variable 'found')
# 404| if (ret > 0) {
# 405| printf("Found tree root at %llu gen %llu level %u\n",
# 406|-> found->start, filter.match_gen, filter.match_level);
# 407| ret = 0;
# 408| }
Error: CLANG_WARNING: [#def12]
btrfs-progs-v6.8/btrfs-map-logical.c:268:10: warning[unix.Malloc]: Potential leak of memory pointed to by 'output_file'
# 266| set_argv0(argv);
# 267| if (check_argc_min(argc - optind, 1))
# 268|-> return 1;
# 269| if (logical == 0)
# 270| usage(&map_logical_cmd, 1);
Error: CLANG_WARNING: [#def13]
btrfs-progs-v6.8/check/mode-common.c:429:19: warning[core.UndefinedBinaryOperatorResult]: The left operand of '>=' is a garbage value
# 427| ret = 0;
# 428| }
# 429|-> if (*highest_ino >= BTRFS_LAST_FREE_OBJECTID)
# 430| ret = -EOVERFLOW;
# 431| btrfs_release_path(path);
Error: CLANG_WARNING: [#def14]
btrfs-progs-v6.8/check/mode-common.c:894:4: warning[deadcode.DeadStores]: Value stored to 'ret' is never read
# 892| if (ret > 0) {
# 893| /* falls back to rdev check */
# 894|-> ret = 0;
# 895| goto out;
# 896| }
Error: CLANG_WARNING: [#def15]
btrfs-progs-v6.8/check/mode-lowmem.c:398:2: warning[core.CallAndMessage]: 2nd function call argument is an uninitialized value
# 396| if (ret)
# 397| goto err;
# 398|-> printf("Created new chunk [%llu %llu]\n", start, nbytes);
# 399|
# 400| flags = BTRFS_BLOCK_GROUP_METADATA;
Error: GCC_ANALYZER_WARNING (CWE-457): [#def16]
btrfs-progs-v6.8/check/mode-lowmem.c:598:17: warning[-Wanalyzer-use-of-uninitialized-value]: use of uninitialized value ‘key.offset’
btrfs-progs-v6.8/check/mode-lowmem.c: scope_hint: In function ‘delete_item.part.0’
# 596| root->objectid, key.objectid, key.type, key.offset);
# 597| else
# 598|-> printf("Deleted root %llu item[%llu, %u, %llu]\n",
# 599| root->objectid, key.objectid, key.type, key.offset);
# 600| return ret;
Error: CLANG_WARNING: [#def17]
btrfs-progs-v6.8/check/mode-lowmem.c:665:2: warning[deadcode.DeadStores]: Value stored to 'generation' is never read
# 663| bytenr = btrfs_header_bytenr(node);
# 664| owner = btrfs_header_owner(node);
# 665|-> generation = btrfs_header_generation(node);
# 666|
# 667| key.objectid = bytenr;
Error: CLANG_WARNING: [#def18]
btrfs-progs-v6.8/check/mode-lowmem.c:861:3: warning[deadcode.DeadStores]: Value stored to 'ret' is never read
# 859| total = btrfs_item_size(node, slot);
# 860| while (cur < total) {
# 861|-> ret = -ENOENT;
# 862| len = btrfs_dir_name_len(node, di);
# 863| data_len = btrfs_dir_data_len(node, di);
Error: CLANG_WARNING: [#def19]
btrfs-progs-v6.8/check/mode-lowmem.c:1136:3: warning[deadcode.DeadStores]: Value stored to 'need_research' is never read
# 1134| /* since after repair, path and the dir item may be changed */
# 1135| if (need_research) {
# 1136|-> need_research = 0;
# 1137| btrfs_release_path(path);
# 1138| ret = btrfs_search_slot(NULL, root, ref_key, path, 0, 0);
Error: CLANG_WARNING: [#def20]
btrfs-progs-v6.8/check/mode-lowmem.c:1704:3: warning[deadcode.DeadStores]: Value stored to 'need_research' is never read
# 1702| /* since after repair, path and the dir item may be changed */
# 1703| if (need_research) {
# 1704|-> need_research = 0;
# 1705| err |= DIR_COUNT_AGAIN;
# 1706| btrfs_release_path(path);
Error: CLANG_WARNING: [#def21]
btrfs-progs-v6.8/check/mode-lowmem.c:1814:10: warning[core.CallAndMessage]: 3rd function call argument is an uninitialized value
# 1812|
# 1813| if (tmp_err && opt_check_repair) {
# 1814|-> ret = repair_dir_item(root, di_key,
# 1815| location.objectid, index,
# 1816| imode_to_type(mode), namebuf,
Error: CLANG_WARNING: [#def22]
btrfs-progs-v6.8/check/mode-lowmem.c:1824:3: warning[core.CallAndMessage]: 3rd function call argument is an uninitialized value
# 1822| }
# 1823| btrfs_release_path(path);
# 1824|-> print_dir_item_err(root, di_key, location.objectid, index,
# 1825| namebuf, name_len, filetype, tmp_err);
# 1826| err |= tmp_err;
Error: CLANG_WARNING: [#def23]
btrfs-progs-v6.8/check/mode-lowmem.c:2507:10: warning[deadcode.DeadStores]: Although the value stored to 'ret' is used in the enclosing expression, the value is never actually read from 'ret'
# 2505| ret2 = btrfs_search_slot(NULL, root, &old_key, path, 0, 0);
# 2506| if (ret2 < 0)
# 2507|-> return ret |= ret2;
# 2508| return ret;
# 2509| }
Error: CLANG_WARNING: [#def24]
btrfs-progs-v6.8/check/mode-lowmem.c:3323:3: warning[deadcode.DeadStores]: Value stored to 'ret' is never read
# 3321|
# 3322| btrfs_mark_buffer_dirty(eb);
# 3323|-> ret = btrfs_update_block_group(trans, disk_bytenr, num_bytes,
# 3324| 1, 0);
# 3325| btrfs_release_path(&path);
Error: CLANG_WARNING: [#def25]
btrfs-progs-v6.8/check/mode-lowmem.c:4008:4: warning[deadcode.DeadStores]: Value stored to 'slot' is never read
# 4006| * skip the leaf to speed up.
# 4007| */
# 4008|-> slot = btrfs_header_nritems(leaf);
# 4009| goto next;
# 4010| }
Error: CLANG_WARNING: [#def26]
btrfs-progs-v6.8/check/mode-lowmem.c:4994:3: warning[deadcode.DeadStores]: Value stored to 'bytenr' is never read
# 4992| WARN_ON(*level >= BTRFS_MAX_LEVEL);
# 4993| cur = path->nodes[*level];
# 4994|-> bytenr = btrfs_header_bytenr(cur);
# 4995| check = nrefs->need_check[*level];
# 4996|
Error: CLANG_WARNING: [#def27]
btrfs-progs-v6.8/check/mode-lowmem.c:5037:4: warning[deadcode.DeadStores]: Value stored to 'ret' is never read
# 5035| }
# 5036|
# 5037|-> ret = 0;
# 5038| if (!check_all)
# 5039| ret = process_one_leaf(root, path, nrefs, level);
Error: CLANG_WARNING: [#def28]
btrfs-progs-v6.8/check/mode-lowmem.c:5231:3: warning[deadcode.DeadStores]: Value stored to 'ret' is never read
# 5229| goto out;
# 5230| if (ret > 0) {
# 5231|-> ret = 0;
# 5232| err |= INODE_ITEM_MISSING;
# 5233| } else {
Error: CLANG_WARNING: [#def29]
btrfs-progs-v6.8/check/mode-lowmem.c:5334:3: warning[deadcode.DeadStores]: Value stored to 'ret' is never read
# 5332| if (ret < 0)
# 5333| goto out;
# 5334|-> ret = 0;
# 5335| }
# 5336|
Error: CLANG_WARNING: [#def30]
btrfs-progs-v6.8/check/qgroup-verify.c:594:6: warning[core.NullDereference]: Access to field 'root' results in a dereference of a null pointer (loaded from variable 'ref')
# 592| BUG_ON(ref == NULL);
# 593|
# 594|-> if (ref->root)
# 595| return ref->root;
# 596| if (ref->parent == bytenr)
Error: CLANG_WARNING: [#def31]
btrfs-progs-v6.8/check/qgroup-verify.c:1156:3: warning[unix.Malloc]: Potential memory leak
# 1154| return ENOMEM;
# 1155|
# 1156|-> ptr += btrfs_extent_inline_ref_size(type);
# 1157| }
# 1158|
Error: CLANG_WARNING: [#def32]
btrfs-progs-v6.8/check/qgroup-verify.c:1189:9: warning[unix.Malloc]: Potential memory leak
# 1187| return ENOMEM;
# 1188|
# 1189|-> return 0;
# 1190| }
# 1191|
Error: CLANG_WARNING: [#def33]
btrfs-progs-v6.8/cmds/balance.c:575:5: warning[deadcode.DeadStores]: Value stored to 'i' is never read
# 573| * we're not in a security-sensitive context.
# 574| */
# 575|-> i = chdir("/");
# 576| close(0);
# 577| close(1);
Error: GCC_ANALYZER_WARNING (CWE-126): [#def34]
btrfs-progs-v6.8/cmds/filesystem-du.c: scope_hint: In function ‘du_calc_file_space’
btrfs-progs-v6.8/cmds/filesystem-du.c:357:50: warning[-Wanalyzer-out-of-bounds]: stack-based buffer over-read
btrfs-progs-v6.8/cmds/filesystem-du.c:18: included_from: Included from here.
btrfs-progs-v6.8/cmds/filesystem-du.c:357:50: note: read of 8 bytes from after the end of ‘buf’
btrfs-progs-v6.8/cmds/filesystem-du.c:357:50: note: valid subscripts for ‘buf’ are ‘[0]’ to ‘[16383]’
# └─────────────────────────┘
# ^
# 355| }
# 356|
# 357|-> fiemap->fm_start = (fm_ext[i - 1].fe_logical +
# 358| fm_ext[i - 1].fe_length);
# 359| } while (!last);
Error: GCC_ANALYZER_WARNING (CWE-126): [#def35]
btrfs-progs-v6.8/cmds/filesystem-du.c:358:50: warning[-Wanalyzer-out-of-bounds]: stack-based buffer over-read
btrfs-progs-v6.8/cmds/filesystem-du.c:358:50: note: read of 8 bytes from after the end of ‘buf’
btrfs-progs-v6.8/cmds/filesystem-du.c:358:50: note: valid subscripts for ‘buf’ are ‘[0]’ to ‘[16383]’
# └─────────────────────────┘
# ^
# 356|
# 357| fiemap->fm_start = (fm_ext[i - 1].fe_logical +
# 358|-> fm_ext[i - 1].fe_length);
# 359| } while (!last);
# 360|
Error: CLANG_WARNING: [#def36]
btrfs-progs-v6.8/cmds/filesystem-usage.c:220:2: warning[core.NonNullParamChecker]: Null pointer passed to 1st parameter expecting 'nonnull'
# 218| }
# 219|
# 220|-> qsort(chunkinfos->data, chunkinfos->length, sizeof(struct chunk_info *),
# 221| cmp_chunk_info);
# 222|
Error: GCC_ANALYZER_WARNING (CWE-688): [#def37]
btrfs-progs-v6.8/cmds/filesystem-usage.c: scope_hint: In function ‘load_chunk_info’
btrfs-progs-v6.8/cmds/filesystem-usage.c:220:9: warning[-Wanalyzer-null-argument]: use of NULL where non-null expected
btrfs-progs-v6.8/include/kerncompat.h:28: included_from: Included from here.
btrfs-progs-v6.8/cmds/filesystem-usage.c:17: included_from: Included from here.
/usr/include/stdlib.h:970:13: note: argument 1 of ‘qsort’ must be non-null
# 218| }
# 219|
# 220|-> qsort(chunkinfos->data, chunkinfos->length, sizeof(struct chunk_info *),
# 221| cmp_chunk_info);
# 222|
Error: CLANG_WARNING: [#def38]
btrfs-progs-v6.8/cmds/filesystem-usage.c:430:2: warning[core.NonNullParamChecker]: Null pointer passed to 1st parameter expecting 'nonnull'
# 428|
# 429| out:
# 430|-> closedir(dir);
# 431| return ret;
# 432| }
Error: CLANG_WARNING: [#def39]
btrfs-progs-v6.8/cmds/filesystem-usage.c:615:3: warning[deadcode.DeadStores]: Value stored to 'ret' is never read
# 613| warning("cannot get space info with statvfs() on '%s': %m", path);
# 614| memset(&statvfs_buf, 0, sizeof(statvfs_buf));
# 615|-> ret = 0;
# 616| }
# 617|
Error: GCC_ANALYZER_WARNING (CWE-688): [#def40]
btrfs-progs-v6.8/cmds/filesystem-usage.c: scope_hint: In function ‘load_device_info’
btrfs-progs-v6.8/cmds/filesystem-usage.c:836:9: warning[-Wanalyzer-null-argument]: use of NULL where non-null expected
/usr/include/stdlib.h:970:13: note: argument 1 of ‘qsort’ must be non-null
# 834| }
# 835|
# 836|-> qsort(devinfos->data, devinfos->length, sizeof(struct device_info *), cmp_device_info);
# 837|
# 838| return 0;
Error: CLANG_WARNING: [#def41]
btrfs-progs-v6.8/cmds/filesystem-usage.c:967:4: warning[deadcode.DeadStores]: Value stored to 'p' is never read
# 965| p = strrchr(devinfo->path, '/');
# 966| if (!p)
# 967|-> p = devinfo->path;
# 968| else
# 969| p++;
Error: CLANG_WARNING: [#def42]
btrfs-progs-v6.8/cmds/filesystem-usage.c:1003:3: warning[deadcode.DeadStores]: Value stored to 'unused' is never read
# 1001| }
# 1002|
# 1003|-> unused = device_get_partition_size(devinfo->path) - total_allocated;
# 1004| unused = devinfo->size - total_allocated;
# 1005|
Error: GCC_ANALYZER_WARNING (CWE-401): [#def43]
btrfs-progs-v6.8/cmds/filesystem.c: scope_hint: In function ‘copy_fs_devices’
btrfs-progs-v6.8/cmds/filesystem.c:533:28: warning[-Wanalyzer-malloc-leak]: leak of ‘dev_copy’
btrfs-progs-v6.8/cmds/filesystem.c:36: included_from: Included from here.
btrfs-progs-v6.8/cmds/filesystem.c:593:9: note: in expansion of macro ‘list_for_each_entry’
btrfs-progs-v6.8/cmds/filesystem.c:532:9: note: in expansion of macro ‘list_for_each_entry’
btrfs-progs-v6.8/cmds/filesystem.c:532:9: note: in expansion of macro ‘list_for_each_entry’
# 531|
# 532| list_for_each_entry(cur_dev, &src->devices, dev_list) {
# 533|-> dev_copy = malloc(sizeof(*dev_copy));
# 534| if (!dev_copy) {
# 535| ret = -ENOMEM;
Error: GCC_ANALYZER_WARNING (CWE-401): [#def44]
btrfs-progs-v6.8/cmds/filesystem.c: scope_hint: In function ‘search_umounted_fs_uuids’
btrfs-progs-v6.8/cmds/filesystem.c:614:25: warning[-Wanalyzer-malloc-leak]: leak of ‘<unknown>’
btrfs-progs-v6.8/cmds/filesystem.c:593:9: note: in expansion of macro ‘list_for_each_entry’
btrfs-progs-v6.8/cmds/filesystem.c:532:9: note: in expansion of macro ‘list_for_each_entry’
# 612| ret = copy_fs_devices(fs_copy, cur_fs);
# 613| if (ret) {
# 614|-> free(fs_copy);
# 615| goto out;
# 616| }
Error: CLANG_WARNING: [#def45]
btrfs-progs-v6.8/cmds/inspect-dump-tree.c:487:3: warning[deadcode.DeadStores]: Value stored to 'ret' is never read
# 485| if (!cache_tree_empty(&block_root)) {
# 486| root = info->chunk_root;
# 487|-> ret = dump_print_tree_blocks(info, &block_root, print_mode);
# 488| goto close_root;
# 489| }
Error: CLANG_WARNING: [#def46]
btrfs-progs-v6.8/cmds/inspect-tree-stats.c:294:3: warning[deadcode.DeadStores]: Value stored to 'group_count' is never read
# 292| pr_verbose(LOG_DEFAULT, "|\n");
# 293| }
# 294|-> group_count = 0;
# 295| }
# 296| }
Error: COMPILER_WARNING: [#def47]
btrfs-progs-v6.8/cmds/inspect.c: scope_hint: In function ‘__ino_to_path_fd’
btrfs-progs-v6.8/cmds/inspect.c:86:35: warning[-Warray-bounds=]: array subscript i_14 is outside array bounds of ‘__u64[0:]’
# 86 | ptr += fspath->val[i];
# | ~~~~~~~~~~~^~~
btrfs-progs-v6.8/kernel-shared/accessors.h:11: included_from: Included from here.
btrfs-progs-v6.8/cmds/inspect.c:35: included_from: Included from here.
btrfs-progs-v6.8/kernel-shared/uapi/btrfs.h:724:17: note: while referencing ‘val’
# 724 | __u64 val[]; /* out */
# | ^~~
# 84| char *str;
# 85| ptr = (u64)(unsigned long)fspath->val;
# 86|-> ptr += fspath->val[i];
# 87| str = (char *)(unsigned long)ptr;
# 88| if (prepend)
Error: COMPILER_WARNING: [#def48]
btrfs-progs-v6.8/cmds/inspect.c: scope_hint: In function ‘cmd_inspect_logical_resolve’
btrfs-progs-v6.8/cmds/inspect.c:294:33: warning[-Wstringop-truncation]: ‘strncpy’ specified bound 4096 equals destination size
# 294 | strncpy(mount_path, mounted, PATH_MAX);
# | ^
# 292| }
# 293|
# 294|-> strncpy(mount_path, mounted, PATH_MAX);
# 295| free(mounted);
# 296|
Error: GCC_ANALYZER_WARNING (CWE-401): [#def49]
btrfs-progs-v6.8/cmds/inspect.c: scope_hint: In function ‘read_chunk_tree’
btrfs-progs-v6.8/cmds/inspect.c:1288:28: warning[-Wanalyzer-malloc-leak]: leak of ‘<unknown>’
btrfs-progs-v6.8/cmds/inspect.c: scope_hint: In function ‘read_chunk_tree’
btrfs-progs-v6.8/cmds/inspect.c: scope_hint: In function ‘read_chunk_tree’
btrfs-progs-v6.8/cmds/inspect.c: scope_hint: In function ‘read_chunk_tree’
btrfs-progs-v6.8/cmds/inspect.c: scope_hint: In function ‘read_chunk_tree’
# 1286| capacity *= 2;
# 1287| tmp = realloc(*chunks, capacity * sizeof(**chunks));
# 1288|-> if (!tmp) {
# 1289| perror("realloc");
# 1290| return -1;
Error: GCC_ANALYZER_WARNING (CWE-688): [#def50]
btrfs-progs-v6.8/cmds/property.c: scope_hint: In function ‘parse_prop’
btrfs-progs-v6.8/cmds/property.c:276:22: warning[-Wanalyzer-null-argument]: use of NULL ‘arg’ where non-null expected
btrfs-progs-v6.8/include/kerncompat.h:30: included_from: Included from here.
btrfs-progs-v6.8/cmds/property.c:17: included_from: Included from here.
/usr/include/string.h:156:12: note: argument 2 of ‘strcmp’ must be non-null
# 274|
# 275| for (; prop->name; prop++) {
# 276|-> if (!strcmp(prop->name, arg)) {
# 277| *prop_ret = prop;
# 278| return 0;
Error: CLANG_WARNING: [#def51]
btrfs-progs-v6.8/cmds/property.c:563:9: warning[core.NullDereference]: Dereference of null pointer (loaded from variable 'name')
# 561| *object = argv[optind++];
# 562| if (optind < argc)
# 563|-> *name = argv[optind++];
# 564| if (optind < argc)
# 565| *value = argv[optind++];
Error: GCC_ANALYZER_WARNING (CWE-476): [#def52]
btrfs-progs-v6.8/cmds/property.c: scope_hint: In function ‘parse_args’
btrfs-progs-v6.8/cmds/property.c:563:23: warning[-Wanalyzer-null-dereference]: dereference of NULL ‘name’
# 561| *object = argv[optind++];
# 562| if (optind < argc)
# 563|-> *name = argv[optind++];
# 564| if (optind < argc)
# 565| *value = argv[optind++];
Error: GCC_ANALYZER_WARNING (CWE-476): [#def53]
btrfs-progs-v6.8/cmds/property.c:565:24: warning[-Wanalyzer-null-dereference]: dereference of NULL ‘value’
# 563| *name = argv[optind++];
# 564| if (optind < argc)
# 565|-> *value = argv[optind++];
# 566|
# 567| if (!*types) {
Error: CLANG_WARNING: [#def54]
btrfs-progs-v6.8/cmds/qgroup.c:355:3: warning[deadcode.DeadStores]: Value stored to 'len' is never read
# 353| break;
# 354| case BTRFS_QGROUP_RFER:
# 355|-> len = print_u64(qgroup->info.referenced, unit_mode, max_len);
# 356| break;
# 357| case BTRFS_QGROUP_EXCL:
Error: CLANG_WARNING: [#def55]
btrfs-progs-v6.8/cmds/qgroup.c:358:3: warning[deadcode.DeadStores]: Value stored to 'len' is never read
# 356| break;
# 357| case BTRFS_QGROUP_EXCL:
# 358|-> len = print_u64(qgroup->info.exclusive, unit_mode, max_len);
# 359| break;
# 360| case BTRFS_QGROUP_PARENT:
Error: CLANG_WARNING: [#def56]
btrfs-progs-v6.8/cmds/qgroup.c:366:4: warning[deadcode.DeadStores]: Value stored to 'len' is never read
# 364| case BTRFS_QGROUP_MAX_RFER:
# 365| if (qgroup->limit.flags & BTRFS_QGROUP_LIMIT_MAX_RFER)
# 366|-> len = print_u64(qgroup->limit.max_referenced,
# 367| unit_mode, max_len);
# 368| else
Error: CLANG_WARNING: [#def57]
btrfs-progs-v6.8/cmds/qgroup.c:369:4: warning[deadcode.DeadStores]: Value stored to 'len' is never read
# 367| unit_mode, max_len);
# 368| else
# 369|-> len = printf("%*s", max_len, "none");
# 370| break;
# 371| case BTRFS_QGROUP_MAX_EXCL:
Error: CLANG_WARNING: [#def58]
btrfs-progs-v6.8/cmds/qgroup.c:373:4: warning[deadcode.DeadStores]: Value stored to 'len' is never read
# 371| case BTRFS_QGROUP_MAX_EXCL:
# 372| if (qgroup->limit.flags & BTRFS_QGROUP_LIMIT_MAX_EXCL)
# 373|-> len = print_u64(qgroup->limit.max_exclusive,
# 374| unit_mode, max_len);
# 375| else
Error: CLANG_WARNING: [#def59]
btrfs-progs-v6.8/cmds/qgroup.c:376:4: warning[deadcode.DeadStores]: Value stored to 'len' is never read
# 374| unit_mode, max_len);
# 375| else
# 376|-> len = printf("%*s", max_len, "none");
# 377| break;
# 378| case BTRFS_QGROUP_CHILD:
Error: GCC_ANALYZER_WARNING (CWE-401): [#def60]
btrfs-progs-v6.8/cmds/qgroup.c: scope_hint: In function ‘get_or_add_qgroup.part.0’
btrfs-progs-v6.8/cmds/qgroup.c:800:40: warning[-Wanalyzer-malloc-leak]: leak of ‘bq’
btrfs-progs-v6.8/cmds/qgroup.c:45: included_from: Included from here.
btrfs-progs-v6.8/common/messages.h:95:9: note: in expansion of macro ‘__btrfs_msg’
btrfs-progs-v6.8/common/messages.h:107:17: note: in expansion of macro ‘__btrfs_error’
btrfs-progs-v6.8/cmds/qgroup.c:798:25: note: in expansion of macro ‘error’
# 798| error("%s", btrfs_util_strerror(uret));
# 799| if (uret == BTRFS_UTIL_ERROR_NO_MEMORY)
# 800|-> return ERR_PTR(-ENOMEM);
# 801| else
# 802| return ERR_PTR(-EIO);
Error: CLANG_WARNING: [#def61]
btrfs-progs-v6.8/cmds/qgroup.c:1970:14: warning[unix.Malloc]: Potential leak of memory pointed to by 'comparer_set'
# 1968| ret = qgroup_parse_sort_string(optarg, &comparer_set);
# 1969| if (ret < 0) {
# 1970|-> errno = -ret;
# 1971| error("cannot parse sort string: %m");
# 1972| return 1;
Error: CLANG_WARNING: [#def62]
btrfs-progs-v6.8/cmds/qgroup.c:1970:14: warning[unix.Malloc]: Potential leak of memory pointed to by 'filter_set'
# 1968| ret = qgroup_parse_sort_string(optarg, &comparer_set);
# 1969| if (ret < 0) {
# 1970|-> errno = -ret;
# 1971| error("cannot parse sort string: %m");
# 1972| return 1;
Error: CLANG_WARNING: [#def63]
btrfs-progs-v6.8/cmds/quota.c:228:3: warning[deadcode.DeadStores]: Value stored to 'e' is never read
# 226| if (wait_for_completion) {
# 227| ret = ioctl(fd, BTRFS_IOC_QUOTA_RESCAN_WAIT, &args);
# 228|-> e = errno;
# 229| if (ret < 0) {
# 230| error("quota rescan wait failed: %m");
Error: GCC_ANALYZER_WARNING (CWE-401): [#def64]
btrfs-progs-v6.8/cmds/reflink.c: scope_hint: In function ‘cmd_reflink_clone’
btrfs-progs-v6.8/cmds/reflink.c:128:33: warning[-Wanalyzer-malloc-leak]: leak of ‘range’
# 126| fallthrough;
# 127| case 'r':
# 128|-> range = malloc(sizeof(struct reflink_range));
# 129| if (!range) {
# 130| error("not enough memory");
Error: GCC_ANALYZER_WARNING (CWE-401): [#def65]
btrfs-progs-v6.8/cmds/reflink.c:131:40: warning[-Wanalyzer-malloc-leak]: leak of ‘range’
# 129| if (!range) {
# 130| error("not enough memory");
# 131|-> return 1;
# 132| }
# 133| INIT_LIST_HEAD(&range->list);
Error: GCC_ANALYZER_WARNING (CWE-1341): [#def66]
btrfs-progs-v6.8/cmds/replace.c: scope_hint: In function ‘cmd_replace_start’
btrfs-progs-v6.8/cmds/replace.c:357:17: warning[-Wanalyzer-fd-double-close]: double ‘close’ of file descriptor ‘btrfs_open_mnt(path)’
# 355| free(dstdev);
# 356| if (fdmnt != -1)
# 357|-> close(fdmnt);
# 358| if (fddstdev != -1)
# 359| close(fddstdev);
Error: CLANG_WARNING: [#def67]
btrfs-progs-v6.8/cmds/rescue-chunk-recover.c:868:24: warning[unix.Malloc]: Use of memory allocated with size zero
# 866| goto out2;
# 867| }
# 868|-> dev_scans[devidx].rc = rc;
# 869| dev_scans[devidx].dev = dev;
# 870| dev_scans[devidx].fd = fd;
Error: CLANG_WARNING: [#def68]
btrfs-progs-v6.8/cmds/rescue-chunk-recover.c:1524:2: warning[deadcode.DeadStores]: Value stored to 'ret' is never read
# 1522| struct btrfs_fs_devices *fs_devices;
# 1523|
# 1524|-> ret = 0;
# 1525| fd = open(path, O_RDONLY);
# 1526| if (fd < 0) {
Error: GCC_ANALYZER_WARNING (CWE-415): [#def69]
btrfs-progs-v6.8/cmds/rescue-super-recover.c: scope_hint: In function ‘free_recover_superblock’
btrfs-progs-v6.8/cmds/rescue-super-recover.c:75:17: warning[-Wanalyzer-double-free]: double-‘free’ of ‘*(struct super_block_record *)MEM[(const struct list_head *)recover_10(D) + 8B].next.device_name’
btrfs-progs-v6.8/kernel-lib/list.h:82:9: note: in expansion of macro ‘WRITE_ONCE’
btrfs-progs-v6.8/cmds/rescue-super-recover.c: scope_hint: In function ‘free_recover_superblock’
btrfs-progs-v6.8/cmds/rescue-super-recover.c:160:9: note: in expansion of macro ‘list_for_each_entry’
btrfs-progs-v6.8/cmds/rescue-super-recover.c: scope_hint: In function ‘free_recover_superblock’
btrfs-progs-v6.8/include/kerncompat.h:623:31: note: in expansion of macro ‘le64_to_cpu’
btrfs-progs-v6.8/kernel-shared/accessors.h:119:16: note: in expansion of macro ‘get_unaligned_le64’
btrfs-progs-v6.8/kernel-shared/accessors.h:929:1: note: in expansion of macro ‘BTRFS_SETGET_STACK_FUNCS’
btrfs-progs-v6.8/cmds/rescue-super-recover.c: scope_hint: In function ‘free_recover_superblock’
btrfs-progs-v6.8/kernel-shared/disk-io.h:156:24: note: in expansion of macro ‘BTRFS_SB_MIRROR_OFFSET’
btrfs-progs-v6.8/cmds/rescue-super-recover.c: scope_hint: In function ‘free_recover_superblock’
btrfs-progs-v6.8/cmds/rescue-super-recover.c: scope_hint: In function ‘free_recover_superblock’
btrfs-progs-v6.8/cmds/rescue-super-recover.c: scope_hint: In function ‘free_recover_superblock’
# 73| struct super_block_record, list);
# 74| list_del_init(&record->list);
# 75|-> free(record->device_name);
# 76| free(record);
# 77| }
Error: GCC_ANALYZER_WARNING (CWE-415): [#def70]
btrfs-progs-v6.8/cmds/rescue-super-recover.c:83:17: warning[-Wanalyzer-double-free]: double-‘free’ of ‘*(struct super_block_record *)MEM[(const struct list_head *)recover_10(D) + 24B].next.device_name’
btrfs-progs-v6.8/kernel-lib/list.h:82:9: note: in expansion of macro ‘WRITE_ONCE’
btrfs-progs-v6.8/cmds/rescue-super-recover.c: scope_hint: In function ‘free_recover_superblock’
btrfs-progs-v6.8/cmds/rescue-super-recover.c:160:9: note: in expansion of macro ‘list_for_each_entry’
btrfs-progs-v6.8/cmds/rescue-super-recover.c: scope_hint: In function ‘free_recover_superblock’
btrfs-progs-v6.8/include/kerncompat.h:623:31: note: in expansion of macro ‘le64_to_cpu’
btrfs-progs-v6.8/kernel-shared/accessors.h:119:16: note: in expansion of macro ‘get_unaligned_le64’
btrfs-progs-v6.8/kernel-shared/accessors.h:929:1: note: in expansion of macro ‘BTRFS_SETGET_STACK_FUNCS’
btrfs-progs-v6.8/cmds/rescue-super-recover.c: scope_hint: In function ‘free_recover_superblock’
btrfs-progs-v6.8/kernel-shared/disk-io.h:156:24: note: in expansion of macro ‘BTRFS_SB_MIRROR_OFFSET’
btrfs-progs-v6.8/cmds/rescue-super-recover.c: scope_hint: In function ‘free_recover_superblock’
btrfs-progs-v6.8/cmds/rescue-super-recover.c: scope_hint: In function ‘free_recover_superblock’
btrfs-progs-v6.8/cmds/rescue-super-recover.c: scope_hint: In function ‘free_recover_superblock’
# 81| struct super_block_record, list);
# 82| list_del_init(&record->list);
# 83|-> free(record->device_name);
# 84| free(record);
# 85| }
Error: CLANG_WARNING: [#def71]
btrfs-progs-v6.8/cmds/restore.c:538:14: warning[core.NullDereference]: Array access (from variable 'name') results in a null pointer dereference
# 536| read_extent_buffer(leaf, name,
# 537| (unsigned long)(di + 1), len);
# 538|-> name[len] = '\0';
# 539| name_len = len;
# 540|
Error: GCC_ANALYZER_WARNING (CWE-126): [#def72]
btrfs-progs-v6.8/cmds/scrub.c: scope_hint: In function ‘scrub_datafile’
btrfs-progs-v6.8/cmds/scrub.c:454:9: warning[-Wanalyzer-out-of-bounds]: stack-based buffer over-read
btrfs-progs-v6.8/cmds/scrub.c:454:9: note: read of 39 bytes from after the end of ‘fsid’
btrfs-progs-v6.8/cmds/scrub.c:454:9: note: valid subscripts for ‘fsid’ are ‘[0]’ to ‘[36]’
# └──────────────────────────────────────────────────────────────────────┘
# ^ ^ ^ ^
# 452|
# 453| datafile[ret] = '.';
# 454|-> strncpy(datafile + ret + 1, fn_local, end - ret - 1);
# 455| ret = strlen(datafile);
# 456|
Error: CLANG_WARNING: [#def73]
btrfs-progs-v6.8/cmds/scrub.c:591:3: warning[unix.Malloc]: Potential leak of memory pointed to by 'p'
# 589| old_avail = avail - i;
# 590| if (old_avail < 0) {
# 591|-> error("scrub record file corrupted near byte %d", i);
# 592| return ERR_PTR(-EINVAL);
# 593| }
Error: CLANG_WARNING: [#def74]
btrfs-progs-v6.8/cmds/scrub.c:698:7: warning[core.NullDereference]: Array access (from variable 'p') results in a null pointer dereference
# 696| ret = 0;
# 697| _SCRUB_KVREAD(ret, &i, data_extents_scrubbed, avail, l,
# 698|-> &p[curr]->p);
# 699| _SCRUB_KVREAD(ret, &i, tree_extents_scrubbed, avail, l,
# 700| &p[curr]->p);
Error: GCC_ANALYZER_WARNING (CWE-688): [#def75]
btrfs-progs-v6.8/cmds/scrub.c: scope_hint: In function ‘mkdir_p’
btrfs-progs-v6.8/cmds/scrub.c:1150:25: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL ‘path’ where non-null expected
<built-in>: note: argument 1 of ‘__builtin_strlen’ must be non-null
# 1148| int ret;
# 1149|
# 1150|-> for (i = 1; i < strlen(path); ++i) {
# 1151| if (path[i] != '/')
# 1152| continue;
Error: CLANG_WARNING: [#def76]
btrfs-progs-v6.8/cmds/scrub.c:1310:10: warning[unix.Malloc]: Potential leak of memory pointed to by 'datafile'
# 1308|
# 1309| if (check_argc_exact(argc - optind, 1))
# 1310|-> return 1;
# 1311|
# 1312| spc.progress = NULL;
Error: CLANG_WARNING: [#def77]
btrfs-progs-v6.8/cmds/scrub.c:1437:3: warning[deadcode.DeadStores]: Value stored to 'ret' is never read
# 1435| ret = prg_fd = socket(AF_UNIX, SOCK_STREAM, 0);
# 1436| while (ret != -1) {
# 1437|-> ret = scrub_datafile(SCRUB_PROGRESS_SOCKET_PATH, fsid, NULL,
# 1438| sock_path, sizeof(sock_path));
# 1439| /* ignore EOVERFLOW, try using a shorter path for the socket */
Error: COMPILER_WARNING: [#def78]
btrfs-progs-v6.8/cmds/scrub.c: scope_hint: In function ‘scrub_start’
btrfs-progs-v6.8/cmds/scrub.c:1441:17: warning[-Wstringop-truncation]: ‘strncpy’ output may be truncated copying 107 bytes from a string of length 4095
# 1441 | strncpy(addr.sun_path, sock_path, sizeof(addr.sun_path) - 1);
# | ^
# 1439| /* ignore EOVERFLOW, try using a shorter path for the socket */
# 1440| addr.sun_path[sizeof(addr.sun_path) - 1] = '\0';
# 1441|-> strncpy(addr.sun_path, sock_path, sizeof(addr.sun_path) - 1);
# 1442| ret = bind(prg_fd, (struct sockaddr *)&addr, sizeof(addr));
# 1443| if (ret != -1 || errno != EADDRINUSE)
Error: CLANG_WARNING: [#def79]
btrfs-progs-v6.8/cmds/scrub.c:1577:9: warning[core.CallAndMessage]: 1st function call argument is an uninitialized value
# 1575| continue;
# 1576| devid = di_args[i].devid;
# 1577|-> ret = pthread_join(t_devs[i], NULL);
# 1578| if (ret) {
# 1579| if (do_print) {
Error: CLANG_WARNING: [#def80]
btrfs-progs-v6.8/cmds/scrub.c:2093:4: warning[deadcode.DeadStores]: Value stored to 'ret' is never read
# 2091| errno = -ret;
# 2092| error("cannot write to the sysfs file: %m");
# 2093|-> ret = 1;
# 2094| }
# 2095| ret = 0;
Error: CLANG_WARNING: [#def81]
btrfs-progs-v6.8/cmds/send.c:648:10: warning[unix.Malloc]: Potential leak of memory pointed to by 'send.clone_sources'
# 646|
# 647| if (check_argc_min(argc - optind, 1))
# 648|-> return 1;
# 649|
# 650| if (outname[0]) {
Error: GCC_ANALYZER_WARNING (CWE-688): [#def82]
btrfs-progs-v6.8/cmds/subvolume.c: scope_hint: In function ‘build_name’
btrfs-progs-v6.8/cmds/subvolume.c:1078:39: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL ‘name’ where non-null expected
btrfs-progs-v6.8/cmds/subvolume.c: scope_hint: In function ‘build_name’
<built-in>: note: argument 1 of ‘__builtin_strlen’ must be non-null
# 1076| return strdup(name);
# 1077|
# 1078|-> full = malloc(strlen(dirid) + strlen(name) + 1);
# 1079| if (!full)
# 1080| return NULL;
Error: CLANG_WARNING: [#def83]
btrfs-progs-v6.8/cmds/subvolume.c:1335:2: warning[unix.Malloc]: Argument to free() is a constant address (18446744073709551604), which is not memory allocated by malloc()
# 1333| break;
# 1334| }
# 1335|-> free(cache_dir_name);
# 1336| free(cache_full_name);
# 1337| pr_verbose(LOG_DEFAULT, "transid marker was %llu\n", max_found);
Error: CLANG_WARNING: [#def84]
btrfs-progs-v6.8/cmds/subvolume.c:1685:2: warning[deadcode.DeadStores]: Value stored to 'err' is never read
# 1683| pr_verbose(LOG_DEFAULT, "\tSnapshot(s):\n");
# 1684|
# 1685|-> err = btrfs_util_create_subvolume_iterator_fd(fd,
# 1686| BTRFS_FS_TREE_OBJECTID, 0,
# 1687| &iter);
Error: CLANG_WARNING: [#def85]
btrfs-progs-v6.8/common/clear-cache.c:373:5: warning[deadcode.DeadStores]: Value stored to 'ret' is never read
# 371| if (btrfs_init_free_space_ctl(cache,
# 372| fs_info->sectorsize)) {
# 373|-> ret = -ENOMEM;
# 374| break;
# 375| }
Error: CLANG_WARNING: [#def86]
btrfs-progs-v6.8/common/device-scan.c:222:7: warning[core.NullDereference]: Access to field 'zone_info' results in a dereference of a null pointer (loaded from variable 'device')
# 220|
# 221| out:
# 222|-> free(device->zone_info);
# 223| free(device);
# 224| free(buf);
Error: GCC_ANALYZER_WARNING (CWE-476): [#def87]
btrfs-progs-v6.8/common/device-scan.c: scope_hint: In function ‘btrfs_add_to_fsid’
btrfs-progs-v6.8/common/device-scan.c:222:20: warning[-Wanalyzer-null-dereference]: dereference of NULL ‘device’
# 220|
# 221| out:
# 222|-> free(device->zone_info);
# 223| free(device);
# 224| free(buf);
Error: CLANG_WARNING: [#def88]
btrfs-progs-v6.8/common/device-utils.c:506:4: warning[deadcode.DeadStores]: Value stored to 'queue_fd' is never read
# 504| queue_fd = sysfs_open_fsid_file(fd, queue);
# 505| if (queue_fd < 0) {
# 506|-> queue_fd = -1;
# 507| ret = 0;
# 508| break;
Error: GCC_ANALYZER_WARNING (CWE-404): [#def89]
btrfs-progs-v6.8/common/format-output.c: scope_hint: In function ‘fmt_set_unquoted’
btrfs-progs-v6.8/common/format-output.c:168:1: warning[-Wanalyzer-va-list-leak]: missing call to ‘va_end’
# 166| }
# 167| return false;
# 168|-> }
# 169|
# 170| void fmt_start(struct format_ctx *fctx, const struct rowspec *spec, int width,
Error: CLANG_WARNING: [#def90]
btrfs-progs-v6.8/common/help.c:196:15: warning[deadcode.DeadStores]: Value stored to 'c' during its initialization is never read
# 194| fputs(*usagestr, outf);
# 195| } else {
# 196|-> const char *c = *usagestr;
# 197|
# 198| for (c = *usagestr; *c; c++) {
Error: COMPILER_WARNING: [#def91]
btrfs-progs-v6.8/common/help.c:313:46: warning[-Wformat-overflow=]: ‘%s’ directive argument is null
# 313 | fprintf(outf, "No usage for '%s'\n", token);
# | ^~
# 311| switch (ret) {
# 312| case -1:
# 313|-> fprintf(outf, "No usage for '%s'\n", token);
# 314| break;
# 315| case -2:
Error: COMPILER_WARNING: [#def92]
btrfs-progs-v6.8/common/help.c: scope_hint: In function ‘usage’
btrfs-progs-v6.8/common/help.c:316:58: warning[-Wformat-overflow=]: ‘%s’ directive argument is null
# 316 | fprintf(outf, "No short description for '%s'\n", token);
# | ^~
# 314| break;
# 315| case -2:
# 316|-> fprintf(outf, "No short description for '%s'\n", token);
# 317| break;
# 318| }
Error: GCC_ANALYZER_WARNING (CWE-457): [#def93]
btrfs-progs-v6.8/check/mode-lowmem.c:37: included_from: Included from here.
btrfs-progs-v6.8/check/mode-lowmem.c: scope_hint: In function ‘delete_item.part.0’
btrfs-progs-v6.8/common/messages.h:87:17: warning[-Wanalyzer-use-of-uninitialized-value]: use of uninitialized value ‘key.offset’
btrfs-progs-v6.8/common/messages.h:95:9: note: in expansion of macro ‘__btrfs_msg’
btrfs-progs-v6.8/common/messages.h:107:17: note: in expansion of macro ‘__btrfs_error’
btrfs-progs-v6.8/check/mode-lowmem.c:595:17: note: in expansion of macro ‘error’
btrfs-progs-v6.8/check/mode-lowmem.c: scope_hint: In function ‘delete_item.part.0’
btrfs-progs-v6.8/common/messages.h:95:9: note: in expansion of macro ‘__btrfs_msg’
btrfs-progs-v6.8/common/messages.h:107:17: note: in expansion of macro ‘__btrfs_error’
btrfs-progs-v6.8/check/mode-lowmem.c:595:17: note: in expansion of macro ‘error’
btrfs-progs-v6.8/common/messages.h:95:9: note: in expansion of macro ‘__btrfs_msg’
btrfs-progs-v6.8/common/messages.h:107:17: note: in expansion of macro ‘__btrfs_error’
btrfs-progs-v6.8/check/mode-lowmem.c:595:17: note: in expansion of macro ‘error’
# 85| do { \
# 86| fputs((prefix), stderr); \
# 87|-> __btrfs_printf((fmt), ##__VA_ARGS__); \
# 88| fputc('\n', stderr); \
# 89| } while (0)
Error: GCC_ANALYZER_WARNING (CWE-401): [#def94]
btrfs-progs-v6.8/common/string-table.c:21: included_from: Included from here.
btrfs-progs-v6.8/common/string-table.c: scope_hint: In function ‘table_vprintf’
btrfs-progs-v6.8/common/messages.h:88:17: warning[-Wanalyzer-malloc-leak]: leak of ‘msg’
btrfs-progs-v6.8/common/messages.h:95:9: note: in expansion of macro ‘__btrfs_msg’
btrfs-progs-v6.8/common/messages.h:107:17: note: in expansion of macro ‘__btrfs_error’
btrfs-progs-v6.8/common/string-table.c:60:17: note: in expansion of macro ‘error’
btrfs-progs-v6.8/common/messages.h:95:9: note: in expansion of macro ‘__btrfs_msg’
btrfs-progs-v6.8/common/messages.h:107:17: note: in expansion of macro ‘__btrfs_error’
btrfs-progs-v6.8/common/string-table.c:60:17: note: in expansion of macro ‘error’
# 86| fputs((prefix), stderr); \
# 87| __btrfs_printf((fmt), ##__VA_ARGS__); \
# 88|-> fputc('\n', stderr); \
# 89| } while (0)
# 90|
Error: CLANG_WARNING: [#def95]
btrfs-progs-v6.8/common/path-utils.c:200:6: warning[core.NonNullParamChecker]: Null pointer passed to 1st parameter expecting 'nonnull'
# 198| return 1;
# 199|
# 200|-> if (stat(a, &st_buf_a) < 0 || stat(b, &st_buf_b) < 0) {
# 201| if (errno == ENOENT)
# 202| return 0;
Error: GCC_ANALYZER_WARNING (CWE-688): [#def96]
btrfs-progs-v6.8/common/path-utils.c: scope_hint: In function ‘is_same_blk_file’
btrfs-progs-v6.8/common/path-utils.c:200:13: warning[-Wanalyzer-null-argument]: use of NULL ‘a’ where non-null expected
btrfs-progs-v6.8/common/path-utils.c:29: included_from: Included from here.
btrfs-progs-v6.8/common/path-utils.c:17: included_from: Included from here.
/usr/include/sys/stat.h:205:12: note: argument 1 of ‘stat’ must be non-null
# 198| return 1;
# 199|
# 200|-> if (stat(a, &st_buf_a) < 0 || stat(b, &st_buf_b) < 0) {
# 201| if (errno == ENOENT)
# 202| return 0;
Error: CLANG_WARNING: [#def97]
btrfs-progs-v6.8/common/path-utils.c:200:32: warning[core.NonNullParamChecker]: Null pointer passed to 1st parameter expecting 'nonnull'
# 198| return 1;
# 199|
# 200|-> if (stat(a, &st_buf_a) < 0 || stat(b, &st_buf_b) < 0) {
# 201| if (errno == ENOENT)
# 202| return 0;
Error: GCC_ANALYZER_WARNING (CWE-688): [#def98]
btrfs-progs-v6.8/common/path-utils.c:200:39: warning[-Wanalyzer-null-argument]: use of NULL ‘b’ where non-null expected
/usr/include/sys/stat.h:205:12: note: argument 1 of ‘stat’ must be non-null
# 198| return 1;
# 199|
# 200|-> if (stat(a, &st_buf_a) < 0 || stat(b, &st_buf_b) < 0) {
# 201| if (errno == ENOENT)
# 202| return 0;
Error: CLANG_WARNING: [#def99]
btrfs-progs-v6.8/common/path-utils.c:357:2: warning[core.NonNullParamChecker]: Null pointer passed to 2nd parameter expecting 'nonnull'
# 355| char *__strncpy_null(char *dest, const char *src, size_t n)
# 356| {
# 357|-> strncpy(dest, src, n);
# 358| if (n > 0)
# 359| dest[n - 1] = '\0';
Error: GCC_ANALYZER_WARNING (CWE-688): [#def100]
btrfs-progs-v6.8/common/path-utils.c: scope_hint: In function ‘__strncpy_null’
btrfs-progs-v6.8/common/path-utils.c:357:9: warning[-Wanalyzer-null-argument]: use of NULL ‘src’ where non-null expected
btrfs-progs-v6.8/common/path-utils.c:33: included_from: Included from here.
btrfs-progs-v6.8/common/path-utils.c:191:17: note: in expansion of macro ‘strncpy_null’
btrfs-progs-v6.8/common/path-utils.c:191:17: note: in expansion of macro ‘strncpy_null’
<built-in>: note: argument 2 of ‘__builtin_strncpy’ must be non-null
# 355| char *__strncpy_null(char *dest, const char *src, size_t n)
# 356| {
# 357|-> strncpy(dest, src, n);
# 358| if (n > 0)
# 359| dest[n - 1] = '\0';
Error: GCC_ANALYZER_WARNING (CWE-688): [#def101]
btrfs-progs-v6.8/common/path-utils.c: scope_hint: In function ‘path_is_in_dir’
btrfs-progs-v6.8/common/path-utils.c:401:16: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL ‘curr_dir’ where non-null expected
btrfs-progs-v6.8/common/path-utils.c:28: included_from: Included from here.
/usr/include/string.h:156:12: note: argument 2 of ‘strcmp’ must be non-null
# 399| int ret;
# 400|
# 401|-> while (strcmp(parent, curr_dir) != 0) {
# 402| if (strcmp(curr_dir, "/") == 0) {
# 403| ret = 0;
Error: CLANG_WARNING: [#def102]
btrfs-progs-v6.8/common/string-table.c:60:3: warning[unix.Malloc]: Potential leak of memory pointed to by 'msg'
# 58|
# 59| if (column >= tab->ncols || row >= tab->nrows) {
# 60|-> error("attempt to write outside of table: col %u row %u fmt %s",
# 61| column, row, fmt);
# 62| return NULL;
Error: CLANG_WARNING: [#def103]
btrfs-progs-v6.8/common/utils.c:1139:18: warning[core.NullDereference]: Access to field 'total_spaces' results in a dereference of an undefined pointer value (loaded from variable 'sargs')
# 1137| return -1;
# 1138|
# 1139|-> for (i = 0; i < sargs->total_spaces; i++) {
# 1140| u64 flags = sargs->spaces[i].flags;
# 1141|
Error: CLANG_WARNING: [#def104]
btrfs-progs-v6.8/common/utils.c:1203:2: warning[core.CallAndMessage]: 1st function call argument is an uninitialized value
# 1201| btrfs_get_string_for_multiple_profiles(fd, &data, &metadata, &mixed,
# 1202| &system, &types);
# 1203|-> free(data);
# 1204| free(metadata);
# 1205| free(mixed);
Error: GCC_ANALYZER_WARNING (CWE-457): [#def105]
btrfs-progs-v6.8/common/utils.c: scope_hint: In function ‘btrfs_test_for_multiple_profiles’
btrfs-progs-v6.8/common/utils.c:1203:9: warning[-Wanalyzer-use-of-uninitialized-value]: use of uninitialized value ‘data’
# 1201| btrfs_get_string_for_multiple_profiles(fd, &data, &metadata, &mixed,
# 1202| &system, &types);
# 1203|-> free(data);
# 1204| free(metadata);
# 1205| free(mixed);
Error: CLANG_WARNING: [#def106]
btrfs-progs-v6.8/common/utils.c:1363:3: warning[deadcode.DeadStores]: Value stored to 'ret' is never read
# 1361| FD_SET(sysfs_fd, &fds);
# 1362|
# 1363|-> ret = read(sysfs_fd, tmp, sizeof(tmp));
# 1364| ret = select(sysfs_fd + 1, NULL, NULL, &fds, &tv);
# 1365| if (ret < 0) {
Error: CLANG_WARNING: [#def107]
btrfs-progs-v6.8/common/utils.c:1378:4: warning[deadcode.DeadStores]: Value stored to 'ret' is never read
# 1376| FD_SET(sysfs_fd, &fds);
# 1377|
# 1378|-> ret = read(sysfs_fd, tmp, sizeof(tmp));
# 1379| /*
# 1380| * Notified before the timeout, check again before
Error: CLANG_WARNING: [#def108]
btrfs-progs-v6.8/convert/main.c:372:6: warning[deadcode.DeadStores]: Value stored to 'cur_len' during its initialization is never read
# 370| {
# 371| u64 cur_off = range->start;
# 372|-> u64 cur_len = range->len;
# 373| u64 hole_start = range->start;
# 374| u64 hole_len;
Error: CLANG_WARNING: [#def109]
btrfs-progs-v6.8/convert/main.c:448:3: warning[deadcode.DeadStores]: Value stored to 'cur_len' is never read
# 446| cur_off += key.offset;
# 447| hole_start = cur_off;
# 448|-> cur_len = range_end(range) - cur_off;
# 449| }
# 450| /*
Error: CLANG_WARNING: [#def110]
btrfs-progs-v6.8/convert/main.c:897:2: warning[deadcode.DeadStores]: Value stored to 'ret' is never read
# 895| }
# 896| /* Handle the reserved ranges */
# 897|-> ret = migrate_reserved_ranges(trans, root, &cctx->used_space, &buf, fd,
# 898| ino, cfg->num_bytes, convert_flags);
# 899|
Error: CLANG_WARNING: [#def111]
btrfs-progs-v6.8/convert/main.c:942:2: warning[deadcode.DeadStores]: Value stored to 'ret' is never read
# 940| key.type = BTRFS_ROOT_ITEM_KEY;
# 941| key.offset = trans->transid;
# 942|-> ret = btrfs_insert_root(trans, root->fs_info->tree_root,
# 943| &key, &root_item);
# 944|
Error: COMPILER_WARNING: [#def112]
btrfs-progs-v6.8/convert/main.c: scope_hint: In function ‘main’
btrfs-progs-v6.8/convert/main.c:2000:41: warning[-Wstringop-truncation]: ‘strncpy’ specified bound 37 equals destination size
# 2000 | strncpy(fsid, optarg, sizeof(fsid));
# | ^
# 1998| return 1;
# 1999| }
# 2000|-> strncpy(fsid, optarg, sizeof(fsid));
# 2001| }
# 2002| break;
Error: GCC_ANALYZER_WARNING (CWE-457): [#def113]
btrfs-progs-v6.8/image/common.c: scope_hint: In function ‘csum_block’
btrfs-progs-v6.8/image/common.c:104:9: warning[-Wanalyzer-use-of-uninitialized-value]: use of uninitialized value ‘__builtin_alloca_with_align((sizetype)btrfs_csum_type_size(0), 8)’
# 102| crc = crc32c(crc, buf + BTRFS_CSUM_SIZE, len - BTRFS_CSUM_SIZE);
# 103| put_unaligned_le32(~crc, result);
# 104|-> memcpy(buf, result, csum_size);
# 105| }
# 106|
Error: CLANG_WARNING: [#def114]
btrfs-progs-v6.8/image/image-create.c:695:2: warning[deadcode.DeadStores]: Value stored to 'ret' is never read
# 693| return ret;
# 694| }
# 695|-> ret = 0;
# 696|
# 697| leaf = path->nodes[0];
Error: CLANG_WARNING: [#def115]
btrfs-progs-v6.8/image/image-create.c:829:2: warning[deadcode.DeadStores]: Value stored to 'ret' is never read
# 827| }
# 828|
# 829|-> ret = copy_space_cache(root, &metadump, &path);
# 830| out:
# 831| ret = flush_pending(&metadump, 1);
Error: CLANG_WARNING: [#def116]
btrfs-progs-v6.8/image/image-restore.c:240:8: warning[core.uninitialized.Branch]: Branch condition evaluates to a garbage value
# 238| &found_size, &physical_dup);
# 239|
# 240|-> if (!physical_dup)
# 241| truncate_item(eb, i, sizeof(*chunk));
# 242| chunk = btrfs_item_ptr(eb, i, struct btrfs_chunk);
Error: CLANG_WARNING: [#def117]
btrfs-progs-v6.8/image/image-restore.c:541:2: warning[core.uninitialized.UndefReturn]: Undefined or garbage value returned to caller
# 539| }
# 540| }
# 541|-> return ret;
# 542|
# 543| write_error:
Error: CLANG_WARNING: [#def118]
btrfs-progs-v6.8/image/image-restore.c:1048:11: warning[unix.StdCLibraryFunctions]: The 1st argument to 'fread' is NULL but should not be NULL
# 1046|
# 1047| if (mdres->compress_method == COMPRESS_ZLIB) {
# 1048|-> ret = fread(tmp, bufsize, 1, mdres->in);
# 1049| if (ret != 1) {
# 1050| error("read error: %m");
Error: CLANG_WARNING: [#def119]
btrfs-progs-v6.8/image/image-restore.c:1074:4: warning[deadcode.DeadStores]: Value stored to 'ret' is never read
# 1072| size = bufsize;
# 1073| }
# 1074|-> ret = 0;
# 1075|
# 1076| ret = read_chunk_block(mdres, buffer, item_bytenr, size,
Error: CLANG_WARNING: [#def120]
btrfs-progs-v6.8/image/image-restore.c:1117:2: warning[deadcode.DeadStores]: Value stored to 'ret' is never read
# 1115| return -EIO;
# 1116| }
# 1117|-> ret = 0;
# 1118|
# 1119| header = &cluster->header;
Error: CLANG_WARNING: [#def121]
btrfs-progs-v6.8/image/image-restore.c:1141:5: warning[core.NullDereference]: Access to field 'bytenr' results in a dereference of a null pointer (loaded from variable 'item')
# 1139| if (!item || le64_to_cpu(item->bytenr) != BTRFS_SUPER_INFO_OFFSET) {
# 1140| error("did not find superblock at %llu",
# 1141|-> le64_to_cpu(item->bytenr));
# 1142| return -EINVAL;
# 1143| }
Error: GCC_ANALYZER_WARNING (CWE-476): [#def122]
btrfs-progs-v6.8/image/image-restore.c:17: included_from: Included from here.
btrfs-progs-v6.8/image/image-restore.c: scope_hint: In function ‘build_chunk_tree’
btrfs-progs-v6.8/image/image-restore.c:1141:49: warning[-Wanalyzer-null-dereference]: dereference of NULL ‘item’
btrfs-progs-v6.8/include/kerncompat.h:604:47: note: in definition of macro ‘le64_to_cpu’
btrfs-progs-v6.8/common/messages.h:95:9: note: in expansion of macro ‘__btrfs_msg’
btrfs-progs-v6.8/common/messages.h:107:17: note: in expansion of macro ‘__btrfs_error’
btrfs-progs-v6.8/image/image-restore.c:1140:17: note: in expansion of macro ‘error’
btrfs-progs-v6.8/include/kerncompat.h:604:47: note: in definition of macro ‘le64_to_cpu’
btrfs-progs-v6.8/include/kerncompat.h:604:47: note: in definition of macro ‘le64_to_cpu’
btrfs-progs-v6.8/image/image-restore.c:43: included_from: Included from here.
btrfs-progs-v6.8/common/messages.h:95:9: note: in expansion of macro ‘__btrfs_msg’
btrfs-progs-v6.8/common/messages.h:107:17: note: in expansion of macro ‘__btrfs_error’
btrfs-progs-v6.8/image/image-restore.c:1140:17: note: in expansion of macro ‘error’
btrfs-progs-v6.8/include/kerncompat.h:604:47: note: in definition of macro ‘le64_to_cpu’
btrfs-progs-v6.8/common/messages.h:95:9: note: in expansion of macro ‘__btrfs_msg’
btrfs-progs-v6.8/common/messages.h:107:17: note: in expansion of macro ‘__btrfs_error’
btrfs-progs-v6.8/image/image-restore.c:1140:17: note: in expansion of macro ‘error’
# 1139| if (!item || le64_to_cpu(item->bytenr) != BTRFS_SUPER_INFO_OFFSET) {
# 1140| error("did not find superblock at %llu",
# 1141|-> le64_to_cpu(item->bytenr));
# 1142| return -EINVAL;
# 1143| }
Error: CLANG_WARNING: [#def123]
btrfs-progs-v6.8/image/image-restore.c:1683:5: warning[deadcode.DeadStores]: Value stored to 'ret' is never read
# 1681| }
# 1682| if (ret > 0) {
# 1683|-> ret = 0;
# 1684| break;
# 1685| }
Error: GCC_ANALYZER_WARNING (CWE-775): [#def124]
btrfs-progs-v6.8/image/image-restore.c: scope_hint: In function ‘restore_metadump’
btrfs-progs-v6.8/image/image-restore.c:1785:32: warning[-Wanalyzer-file-leak]: leak of FILE ‘in’
# 1783| if (!in) {
# 1784| error("unable to open metadump image: %m");
# 1785|-> return 1;
# 1786| }
# 1787| }
Error: GCC_ANALYZER_WARNING (CWE-401): [#def125]
btrfs-progs-v6.8/image/image-restore.c:1785:32: warning[-Wanalyzer-malloc-leak]: leak of ‘in’
# 1783| if (!in) {
# 1784| error("unable to open metadump image: %m");
# 1785|-> return 1;
# 1786| }
# 1787| }
Error: CLANG_WARNING: [#def126]
btrfs-progs-v6.8/image/image-restore.c:1842:4: warning[deadcode.DeadStores]: Value stored to 'ret' is never read
# 1840| le64_to_cpu(header->bytenr) != bytenr) {
# 1841| error("bad header in metadump image");
# 1842|-> ret = -EIO;
# 1843| break;
# 1844| }
Error: GCC_ANALYZER_WARNING (CWE-122): [#def127]
btrfs-progs-v6.8/image/sanitize.c: scope_hint: In function ‘find_collision_calc_suffix’
btrfs-progs-v6.8/image/sanitize.c:122:27: warning[-Wanalyzer-out-of-bounds]: heap-based buffer overflow
btrfs-progs-v6.8/kernel-shared/ctree.h:34: included_from: Included from here.
btrfs-progs-v6.8/image/sanitize.c:24: included_from: Included from here.
btrfs-progs-v6.8/crypto/crc32c.h:27:75: note: in definition of macro ‘crc32c’
# 120| }
# 121| for (i = 0; i < 4; i++)
# 122|-> suffix[i] = (desired_crc >> i * 8) & 0xFF;
# 123| }
# 124|
Error: GCC_ANALYZER_WARNING (CWE-122): [#def128]
btrfs-progs-v6.8/image/sanitize.c: scope_hint: In function ‘find_collision_is_suffix_valid’
btrfs-progs-v6.8/image/sanitize.c:134:19: warning[-Wanalyzer-out-of-bounds]: heap-based buffer over-read
btrfs-progs-v6.8/crypto/crc32c.h:27:75: note: in definition of macro ‘crc32c’
# └─────────────────┘
# ^
# 132|
# 133| for (i = 0; i < 4; i++) {
# 134|-> c = suffix[i];
# 135| if (c < ' ' || c > 126 || c == '/')
# 136| return false;
Error: CLANG_WARNING: [#def129]
btrfs-progs-v6.8/image/sanitize.c:365:1: warning[unix.Malloc]: Potential leak of memory pointed to by 'garbage'
# 363| free(garbage);
# 364| }
# 365|-> }
# 366|
# 367| static void sanitize_inode_ref(enum sanitize_mode sanitize,
Error: CLANG_WARNING: [#def130]
btrfs-progs-v6.8/image/sanitize.c:418:1: warning[unix.Malloc]: Potential leak of memory pointed to by 'garbage'
# 416| free(garbage);
# 417| }
# 418|-> }
# 419|
# 420| static void sanitize_xattr(struct extent_buffer *eb, int slot)
Error: GCC_ANALYZER_WARNING (CWE-401): [#def131]
btrfs-progs-v6.8/include/kerncompat.h:390:23: warning[-Wanalyzer-malloc-leak]: leak of ‘new_eb’
btrfs-progs-v6.8/kernel-shared/volumes.c:2845:26: note: in expansion of macro ‘kmalloc’
btrfs-progs-v6.8/kernel-shared/volumes.c:2800:9: note: in expansion of macro ‘kfree’
btrfs-progs-v6.8/kernel-shared/volumes.c:2845:26: note: in expansion of macro ‘kmalloc’
btrfs-progs-v6.8/kernel-shared/volumes.c:2845:26: note: in expansion of macro ‘kmalloc’
btrfs-progs-v6.8/kernel-shared/volumes.c:2845:26: note: in expansion of macro ‘kmalloc’
btrfs-progs-v6.8/kernel-shared/volumes.c:2845:26: note: in expansion of macro ‘kmalloc’
# 388| * kmalloc/kfree
# 389| */
# 390|-> #define kmalloc(x, y) malloc(x)
# 391| #define kzalloc(x, y) calloc(1, x)
# 392| #define kstrdup(x, y) strdup(x)
Error: GCC_ANALYZER_WARNING (CWE-401): [#def132]
btrfs-progs-v6.8/include/kerncompat.h:393:18: warning[-Wanalyzer-malloc-leak]: leak of ‘new_eb’
btrfs-progs-v6.8/kernel-shared/volumes.c:2892:9: note: in expansion of macro ‘kfree’
btrfs-progs-v6.8/kernel-shared/volumes.c:2800:9: note: in expansion of macro ‘kfree’
btrfs-progs-v6.8/kernel-shared/volumes.c:2845:26: note: in expansion of macro ‘kmalloc’
btrfs-progs-v6.8/kernel-shared/volumes.c:2845:26: note: in expansion of macro ‘kmalloc’
btrfs-progs-v6.8/kernel-shared/volumes.c:2892:9: note: in expansion of macro ‘kfree’
# 391| #define kzalloc(x, y) calloc(1, x)
# 392| #define kstrdup(x, y) strdup(x)
# 393|-> #define kfree(x) free(x)
# 394| #define vmalloc(x) malloc(x)
# 395| #define vfree(x) free(x)
Error: GCC_ANALYZER_WARNING (CWE-476): [#def133]
btrfs-progs-v6.8/kernel-shared/extent_io.c:19: included_from: Included from here.
btrfs-progs-v6.8/include/kerncompat.h:393:18: warning[-Wanalyzer-null-dereference]: dereference of NULL ‘pointers’
btrfs-progs-v6.8/kernel-shared/extent_io.c:419:17: note: in expansion of macro ‘kfree’
btrfs-progs-v6.8/include/kerncompat.h:393:23: note: in definition of macro ‘kfree’
btrfs-progs-v6.8/kernel-shared/extent_io.c:419:17: note: in expansion of macro ‘kfree’
# 391| #define kzalloc(x, y) calloc(1, x)
# 392| #define kstrdup(x, y) strdup(x)
# 393|-> #define kfree(x) free(x)
# 394| #define vmalloc(x) malloc(x)
# 395| #define vfree(x) free(x)
Error: GCC_ANALYZER_WARNING (CWE-127): [#def134]
btrfs-progs-v6.8/cmds/filesystem.c:17: included_from: Included from here.
btrfs-progs-v6.8/cmds/filesystem.c: scope_hint: In function ‘map_seed_devices’
btrfs-progs-v6.8/include/kerncompat.h:462:46: warning[-Wanalyzer-out-of-bounds]: stack-based buffer under-read
btrfs-progs-v6.8/kernel-lib/list.h:565:9: note: in expansion of macro ‘container_of’
btrfs-progs-v6.8/kernel-lib/list.h:576:9: note: in expansion of macro ‘list_entry’
btrfs-progs-v6.8/cmds/filesystem.c:640:26: note: in expansion of macro ‘list_first_entry’
btrfs-progs-v6.8/kernel-lib/list.h:71:26: note: in definition of macro ‘LIST_HEAD’
btrfs-progs-v6.8/cmds/filesystem.c:637:9: note: in expansion of macro ‘list_for_each_entry’
btrfs-progs-v6.8/kernel-lib/list.h:565:9: note: in expansion of macro ‘container_of’
btrfs-progs-v6.8/kernel-lib/list.h:576:9: note: in expansion of macro ‘list_entry’
btrfs-progs-v6.8/cmds/filesystem.c:640:26: note: in expansion of macro ‘list_first_entry’
# └──────────────────────────────────────┘
# ^
# 460|
# 461| #define container_of(ptr, type, member) ({ \
# 462|-> const typeof( ((type *)0)->member ) *__mptr = (ptr); \
# 463| (type *)( (char *)__mptr - offsetof(type,member) );})
# 464| #ifndef __bitwise
Error: GCC_ANALYZER_WARNING (CWE-476): [#def135]
btrfs-progs-v6.8/include/kerncompat.h:606:25: warning[-Wanalyzer-null-dereference]: dereference of NULL ‘leaf’
btrfs-progs-v6.8/include/kerncompat.h:619:31: note: in expansion of macro ‘le32_to_cpu’
btrfs-progs-v6.8/kernel-shared/accessors.h:107:16: note: in expansion of macro ‘get_unaligned_le32’
btrfs-progs-v6.8/kernel-shared/accessors.h:720:1: note: in expansion of macro ‘BTRFS_SETGET_HEADER_FUNCS’
btrfs-progs-v6.8/kernel-shared/ctree.c: scope_hint: In function ‘btrfs_leaf_free_space’
btrfs-progs-v6.8/include/kerncompat.h:619:31: note: in expansion of macro ‘le32_to_cpu’
btrfs-progs-v6.8/kernel-shared/accessors.h:107:16: note: in expansion of macro ‘get_unaligned_le32’
btrfs-progs-v6.8/kernel-shared/accessors.h:720:1: note: in expansion of macro ‘BTRFS_SETGET_HEADER_FUNCS’
btrfs-progs-v6.8/kernel-shared/ctree.c: scope_hint: In function ‘btrfs_leaf_free_space’
btrfs-progs-v6.8/include/kerncompat.h:619:31: note: in expansion of macro ‘le32_to_cpu’
btrfs-progs-v6.8/kernel-shared/accessors.h:107:16: note: in expansion of macro ‘get_unaligned_le32’
btrfs-progs-v6.8/kernel-shared/accessors.h:720:1: note: in expansion of macro ‘BTRFS_SETGET_HEADER_FUNCS’
# 604| #define le64_to_cpu(x) ((__force u64)(__le64)(x))
# 605| #define cpu_to_le32(x) ((__force __le32)(u32)(x))
# 606|-> #define le32_to_cpu(x) ((__force u32)(__le32)(x))
# 607| #define cpu_to_le16(x) ((__force __le16)(u16)(x))
# 608| #define le16_to_cpu(x) ((__force u16)(__le16)(x))
Error: GCC_ANALYZER_WARNING (CWE-401): [#def136]
btrfs-progs-v6.8/include/kerncompat.h:651:13: warning[-Wanalyzer-malloc-leak]: leak of ‘e’
btrfs-progs-v6.8/kernel-lib/list.h:120:9: note: in expansion of macro ‘WRITE_ONCE’
btrfs-progs-v6.8/cmds/inspect.c: scope_hint: In function ‘add_dev_extent’
btrfs-progs-v6.8/include/kerncompat.h:623:31: note: in expansion of macro ‘le64_to_cpu’
btrfs-progs-v6.8/kernel-shared/accessors.h:119:16: note: in expansion of macro ‘get_unaligned_le64’
btrfs-progs-v6.8/kernel-shared/accessors.h:370:1: note: in expansion of macro ‘BTRFS_SETGET_STACK_FUNCS’
btrfs-progs-v6.8/cmds/inspect.c: scope_hint: In function ‘add_dev_extent’
btrfs-progs-v6.8/cmds/inspect.c:33: included_from: Included from here.
btrfs-progs-v6.8/kernel-lib/list.h:120:9: note: in expansion of macro ‘WRITE_ONCE’
# 649| #define WRITE_ONCE(x, val) \
# 650| do { \
# 651|-> (x) = (val); \
# 652| } while (0)
# 653|
Error: CLANG_WARNING: [#def137]
btrfs-progs-v6.8/kernel-shared/extent-io-tree.c:3: included_from: Included from here.
btrfs-progs-v6.8/include/kerncompat.h:673:2: warning[unix.Malloc]: Use of memory after it is freed
# 671| static inline void refcount_inc(refcount_t *ref)
# 672| {
# 673|-> ref->refs++;
# 674| }
# 675|
Error: CLANG_WARNING: [#def138]
btrfs-progs-v6.8/kernel-shared/extent_io.c:26: included_from: Included from here.
btrfs-progs-v6.8/kernel-lib/raid56.h:27: included_from: Included from here.
btrfs-progs-v6.8/kernel-lib/bitops.h:32:34: warning[core.BitwiseShift]: Right operand is negative in left shift
# 30| static inline void set_bit(int nr, unsigned long *addr)
# 31| {
# 32|-> addr[nr / BITS_PER_LONG] |= 1UL << (nr % BITS_PER_LONG);
# 33| }
# 34|
Error: GCC_ANALYZER_WARNING (CWE-476): [#def139]
btrfs-progs-v6.8/kernel-lib/list.h:133:9: warning[-Wanalyzer-null-dereference]: dereference of NULL ‘*fs_info.fs_devices’
btrfs-progs-v6.8/kernel-shared/volumes.c: scope_hint: In function ‘read_one_chunk’
btrfs-progs-v6.8/kernel-shared/ctree.h:31: included_from: Included from here.
btrfs-progs-v6.8/kernel-shared/volumes.c: scope_hint: In function ‘read_one_chunk’
# 131| static inline void list_add(struct list_head *xnew, struct list_head *head)
# 132| {
# 133|-> __list_add(xnew, head, head->next);
# 134| }
# 135|
Error: GCC_ANALYZER_WARNING (CWE-416): [#def140]
btrfs-progs-v6.8/kernel-lib/list.h:182:9: warning[-Wanalyzer-use-after-free]: use after ‘free’ of ‘((const struct list_head *)((char *)recover + 8))[1].next’
btrfs-progs-v6.8/cmds/rescue-super-recover.c: scope_hint: In function ‘free_recover_superblock’
btrfs-progs-v6.8/kernel-lib/list.h:82:9: note: in expansion of macro ‘WRITE_ONCE’
btrfs-progs-v6.8/cmds/rescue-super-recover.c: scope_hint: In function ‘free_recover_superblock’
btrfs-progs-v6.8/cmds/rescue-super-recover.c:160:9: note: in expansion of macro ‘list_for_each_entry’
btrfs-progs-v6.8/cmds/rescue-super-recover.c: scope_hint: In function ‘free_recover_superblock’
btrfs-progs-v6.8/include/kerncompat.h:623:31: note: in expansion of macro ‘le64_to_cpu’
btrfs-progs-v6.8/kernel-shared/accessors.h:119:16: note: in expansion of macro ‘get_unaligned_le64’
btrfs-progs-v6.8/kernel-shared/accessors.h:929:1: note: in expansion of macro ‘BTRFS_SETGET_STACK_FUNCS’
btrfs-progs-v6.8/cmds/rescue-super-recover.c: scope_hint: In function ‘free_recover_superblock’
btrfs-progs-v6.8/kernel-shared/disk-io.h:156:24: note: in expansion of macro ‘BTRFS_SB_MIRROR_OFFSET’
btrfs-progs-v6.8/cmds/rescue-super-recover.c: scope_hint: In function ‘free_recover_superblock’
btrfs-progs-v6.8/cmds/rescue-super-recover.c: scope_hint: In function ‘free_recover_superblock’
# 180| return;
# 181|
# 182|-> __list_del(entry->prev, entry->next);
# 183| }
# 184|
Error: GCC_ANALYZER_WARNING (CWE-416): [#def141]
btrfs-progs-v6.8/kernel-lib/list.h:182:9: warning[-Wanalyzer-use-after-free]: use after ‘free’ of ‘*(const struct list_head *)((char *)recover + 8).next’
btrfs-progs-v6.8/cmds/rescue-super-recover.c: scope_hint: In function ‘free_recover_superblock’
btrfs-progs-v6.8/kernel-lib/list.h:82:9: note: in expansion of macro ‘WRITE_ONCE’
btrfs-progs-v6.8/cmds/rescue-super-recover.c: scope_hint: In function ‘free_recover_superblock’
btrfs-progs-v6.8/cmds/rescue-super-recover.c:160:9: note: in expansion of macro ‘list_for_each_entry’
btrfs-progs-v6.8/cmds/rescue-super-recover.c: scope_hint: In function ‘free_recover_superblock’
btrfs-progs-v6.8/include/kerncompat.h:623:31: note: in expansion of macro ‘le64_to_cpu’
btrfs-progs-v6.8/kernel-shared/accessors.h:119:16: note: in expansion of macro ‘get_unaligned_le64’
btrfs-progs-v6.8/kernel-shared/accessors.h:929:1: note: in expansion of macro ‘BTRFS_SETGET_STACK_FUNCS’
btrfs-progs-v6.8/cmds/rescue-super-recover.c: scope_hint: In function ‘free_recover_superblock’
btrfs-progs-v6.8/kernel-shared/disk-io.h:156:24: note: in expansion of macro ‘BTRFS_SB_MIRROR_OFFSET’
btrfs-progs-v6.8/cmds/rescue-super-recover.c: scope_hint: In function ‘free_recover_superblock’
btrfs-progs-v6.8/cmds/rescue-super-recover.c: scope_hint: In function ‘free_recover_superblock’
# 180| return;
# 181|
# 182|-> __list_del(entry->prev, entry->next);
# 183| }
# 184|
Error: CLANG_WARNING: [#def142]
btrfs-progs-v6.8/cmds/inspect.c:33: included_from: Included from here.
btrfs-progs-v6.8/kernel-lib/list.h:182:13: warning[unix.Malloc]: Use of memory after it is freed
# 180| return;
# 181|
# 182|-> __list_del(entry->prev, entry->next);
# 183| }
# 184|
Error: CLANG_WARNING: [#def143]
btrfs-progs-v6.8/kernel-lib/list_sort.c:80:20: warning[core.NullDereference]: Access to field 'prev' results in a dereference of a null pointer (loaded from field 'next')
# 78| (*cmp)(priv, tail->next, tail->next);
# 79|
# 80|-> tail->next->prev = tail;
# 81| tail = tail->next;
# 82| } while (tail->next);
Error: GCC_ANALYZER_WARNING (CWE-457): [#def144]
btrfs-progs-v6.8/kernel-shared/accessors.h:52:9: warning[-Wanalyzer-use-of-uninitialized-value]: use of uninitialized value ‘info’
btrfs-progs-v6.8/kernel-shared/accessors.h:389:9: note: in expansion of macro ‘write_eb_member’
btrfs-progs-v6.8/convert/common.c: scope_hint: In function ‘insert_temp_extent_item’
btrfs-progs-v6.8/include/kerncompat.h:619:31: note: in expansion of macro ‘le32_to_cpu’
btrfs-progs-v6.8/kernel-shared/accessors.h:107:16: note: in expansion of macro ‘get_unaligned_le32’
btrfs-progs-v6.8/kernel-shared/accessors.h:720:1: note: in expansion of macro ‘BTRFS_SETGET_HEADER_FUNCS’
btrfs-progs-v6.8/convert/common.c: scope_hint: In function ‘insert_temp_extent_item’
btrfs-progs-v6.8/kernel-shared/accessors.h:622:1: note: in expansion of macro ‘BTRFS_SETGET_STACK_FUNCS’
btrfs-progs-v6.8/convert/common.c: scope_hint: In function ‘insert_temp_extent_item’
btrfs-progs-v6.8/kernel-shared/accessors.h:389:9: note: in expansion of macro ‘write_eb_member’
# 50|
# 51| #define write_eb_member(eb, ptr, type, member, result) (\
# 52|-> write_extent_buffer(eb, (char *)(result), \
# 53| ((unsigned long)(ptr)) + \
# 54| offsetof(type, member), \
Error: CLANG_WARNING: [#def145]
btrfs-progs-v6.8/image/image-restore.c:34: included_from: Included from here.
btrfs-progs-v6.8/kernel-shared/accessors.h:928:1: warning[core.uninitialized.UndefReturn]: Undefined or garbage value returned to caller
# 926| /* struct btrfs_super_block */
# 927| BTRFS_SETGET_STACK_FUNCS(super_bytenr, struct btrfs_super_block, bytenr, 64);
# 928|-> BTRFS_SETGET_STACK_FUNCS(super_flags, struct btrfs_super_block, flags, 64);
# 929| BTRFS_SETGET_STACK_FUNCS(super_generation, struct btrfs_super_block,
# 930| generation, 64);
Error: CLANG_WARNING: [#def146]
btrfs-progs-v6.8/kernel-shared/accessors.h:949:1: warning[core.uninitialized.UndefReturn]: Undefined or garbage value returned to caller
# 947| BTRFS_SETGET_STACK_FUNCS(super_bytes_used, struct btrfs_super_block,
# 948| bytes_used, 64);
# 949|-> BTRFS_SETGET_STACK_FUNCS(super_sectorsize, struct btrfs_super_block,
# 950| sectorsize, 32);
# 951| BTRFS_SETGET_STACK_FUNCS(super_nodesize, struct btrfs_super_block,
Error: CLANG_WARNING: [#def147]
btrfs-progs-v6.8/kernel-shared/backref.c:145:2: warning[unix.Malloc]: Use of memory after it is freed
# 143| static struct __prelim_ref *list_first_pref(struct list_head *head)
# 144| {
# 145|-> return list_first_entry(head, struct __prelim_ref, list);
# 146| }
# 147|
Error: CLANG_WARNING: [#def148]
btrfs-progs-v6.8/kernel-shared/ctree.c:1102:4: warning[deadcode.DeadStores]: Value stored to 'ret' is never read
# 1100| }
# 1101| if (wret < 0)
# 1102|-> ret = wret;
# 1103| if (wret == 0) {
# 1104| struct btrfs_disk_key disk_key;
Error: CLANG_WARNING: [#def149]
btrfs-progs-v6.8/kernel-shared/ctree.c:1145:4: warning[deadcode.DeadStores]: Value stored to 'ret' is never read
# 1143| }
# 1144| if (wret < 0)
# 1145|-> ret = wret;
# 1146| if (wret == 0) {
# 1147| struct btrfs_disk_key disk_key;
Error: CLANG_WARNING: [#def150]
btrfs-progs-v6.8/kernel-shared/ctree.c:1779:40: warning[core.NullDereference]: Access to field 'transid' results in a dereference of a null pointer (loaded from variable 'trans')
# 1777|
# 1778| c = path->nodes[level];
# 1779|-> WARN_ON(btrfs_header_generation(c) != trans->transid);
# 1780| if (c == root->node) {
# 1781| /* trying to split the root, lets make a new one */
Error: CLANG_WARNING: [#def151]
btrfs-progs-v6.8/kernel-shared/ctree.c:1876:9: warning[core.NullDereference]: Access to field 'nodesize' results in a dereference of a null pointer (loaded from field 'fs_info')
# 1874|
# 1875| BUG_ON(!leaf->fs_info);
# 1876|-> BUG_ON(leaf->fs_info->nodesize != leaf->len);
# 1877| leaf_data_size = BTRFS_LEAF_DATA_SIZE(leaf->fs_info);
# 1878| ret = leaf_data_size - leaf_space_used(leaf, 0 ,nritems);
Error: CLANG_WARNING: [#def152]
btrfs-progs-v6.8/kernel-shared/ctree.c:2667:2: warning[deadcode.DeadStores]: Value stored to 'data_end' is never read
# 2665| data_end, old_data - data_end);
# 2666|
# 2667|-> data_end = old_data;
# 2668| old_size = btrfs_item_size(leaf, slot);
# 2669| btrfs_set_item_size(leaf, slot, old_size + data_size);
Error: GCC_ANALYZER_WARNING (CWE-126): [#def153]
btrfs-progs-v6.8/kernel-shared/delayed-ref.c: scope_hint: In function ‘comp_data_refs’
btrfs-progs-v6.8/kernel-shared/delayed-ref.c:77:25: warning[-Wanalyzer-out-of-bounds]: heap-based buffer over-read
btrfs-progs-v6.8/kernel-shared/delayed-ref.c:20: included_from: Included from here.
btrfs-progs-v6.8/kernel-shared/delayed-ref.c:632:15: note: in expansion of macro ‘kmalloc’
btrfs-progs-v6.8/kernel-shared/delayed-ref.c:487:9: note: in expansion of macro ‘BUG_ON’
btrfs-progs-v6.8/kernel-shared/delayed-ref.c: scope_hint: In function ‘comp_data_refs’
btrfs-progs-v6.8/kernel-shared/delayed-ref.c: scope_hint: In function ‘comp_data_refs’
btrfs-progs-v6.8/kernel-shared/delayed-ref.c:77:25: note: read of 8 bytes from after the end of the region
# └───────────────────────┘
# ^
# 75| if (ref1->objectid > ref2->objectid)
# 76| return 1;
# 77|-> if (ref1->offset < ref2->offset)
# 78| return -1;
# 79| if (ref1->offset > ref2->offset)
Error: CLANG_WARNING: [#def154]
btrfs-progs-v6.8/kernel-shared/delayed-ref.c:330:4: warning[deadcode.DeadStores]: Value stored to 'start' is never read
# 328| return NULL;
# 329| delayed_refs->run_delayed_start = 0;
# 330|-> start = 0;
# 331| loop = true;
# 332| goto again;
Error: GCC_ANALYZER_WARNING (CWE-476): [#def155]
btrfs-progs-v6.8/kernel-shared/disk-io.c: scope_hint: In function ‘__open_ctree_fd’
btrfs-progs-v6.8/kernel-shared/disk-io.c:1564:23: warning[-Wanalyzer-null-dereference]: dereference of NULL ‘fs_devices’
btrfs-progs-v6.8/include/kerncompat.h:29: included_from: Included from here.
btrfs-progs-v6.8/kernel-shared/disk-io.c:19: included_from: Included from here.
# 1562| disk_super = fs_info->super_copy;
# 1563| if (flags & OPEN_CTREE_RECOVER_SUPER)
# 1564|-> ret = btrfs_read_dev_super(fs_devices->latest_bdev, disk_super,
# 1565| sb_bytenr, SBREAD_RECOVER);
# 1566| else if (flags & OPEN_CTREE_USE_LATEST_BDEV)
Error: CLANG_WARNING: [#def156]
btrfs-progs-v6.8/kernel-shared/disk-io.c:1564:30: warning[core.NullDereference]: Access to field 'latest_bdev' results in a dereference of a null pointer (loaded from variable 'fs_devices')
# 1562| disk_super = fs_info->super_copy;
# 1563| if (flags & OPEN_CTREE_RECOVER_SUPER)
# 1564|-> ret = btrfs_read_dev_super(fs_devices->latest_bdev, disk_super,
# 1565| sb_bytenr, SBREAD_RECOVER);
# 1566| else if (flags & OPEN_CTREE_USE_LATEST_BDEV)
Error: GCC_ANALYZER_WARNING (CWE-476): [#def157]
btrfs-progs-v6.8/kernel-shared/disk-io.c:1567:23: warning[-Wanalyzer-null-dereference]: dereference of NULL ‘fs_devices’
# 1565| sb_bytenr, SBREAD_RECOVER);
# 1566| else if (flags & OPEN_CTREE_USE_LATEST_BDEV)
# 1567|-> ret = btrfs_read_dev_super(fs_devices->latest_bdev, disk_super,
# 1568| sb_bytenr, sbflags);
# 1569| else
Error: CLANG_WARNING: [#def158]
btrfs-progs-v6.8/kernel-shared/disk-io.c:1567:30: warning[core.NullDereference]: Access to field 'latest_bdev' results in a dereference of a null pointer (loaded from variable 'fs_devices')
# 1565| sb_bytenr, SBREAD_RECOVER);
# 1566| else if (flags & OPEN_CTREE_USE_LATEST_BDEV)
# 1567|-> ret = btrfs_read_dev_super(fs_devices->latest_bdev, disk_super,
# 1568| sb_bytenr, sbflags);
# 1569| else
Error: CLANG_WARNING: [#def159]
btrfs-progs-v6.8/kernel-shared/disk-io.c:1585:10: warning[core.NonNullParamChecker]: Null pointer passed to 2nd parameter expecting 'nonnull'
# 1583| /* CHECK: ignore_csum_mismatch */
# 1584|
# 1585|-> ASSERT(!memcmp(disk_super->fsid, fs_devices->fsid, BTRFS_FSID_SIZE));
# 1586| if (btrfs_fs_incompat(fs_info, METADATA_UUID))
# 1587| ASSERT(!memcmp(disk_super->metadata_uuid,
Error: CLANG_WARNING: [#def160]
btrfs-progs-v6.8/kernel-shared/extent-io-tree.c:270:16: warning[unix.Malloc]: Use of memory after it is freed
# 268| entry = rb_entry(prev, struct extent_state, rb_node);
# 269|
# 270|-> if (offset < entry->start)
# 271| node = &(*node)->rb_left;
# 272| else if (offset > entry->end)
Error: CLANG_WARNING: [#def161]
btrfs-progs-v6.8/kernel-shared/extent-io-tree.c:1059:18: warning[core.NullDereference]: Dereference of null pointer (loaded from variable 'failed_start')
# 1057| if (state->start == start && state->end <= end) {
# 1058| if (state->state & exclusive_bits) {
# 1059|-> *failed_start = state->start;
# 1060| cache_state(state, failed_state);
# 1061| err = -EEXIST;
Error: CLANG_WARNING: [#def162]
btrfs-progs-v6.8/kernel-shared/extent-io-tree.c:1095:18: warning[core.NullDereference]: Dereference of null pointer (loaded from variable 'failed_start')
# 1093| if (state->start < start) {
# 1094| if (state->state & exclusive_bits) {
# 1095|-> *failed_start = start;
# 1096| cache_state(state, failed_state);
# 1097| err = -EEXIST;
Error: CLANG_WARNING: [#def163]
btrfs-progs-v6.8/kernel-shared/extent-io-tree.c:1176:18: warning[core.NullDereference]: Dereference of null pointer (loaded from variable 'failed_start')
# 1174| if (state->start <= end && state->end > end) {
# 1175| if (state->state & exclusive_bits) {
# 1176|-> *failed_start = start;
# 1177| cache_state(state, failed_state);
# 1178| err = -EEXIST;
Error: CLANG_WARNING: [#def164]
btrfs-progs-v6.8/kernel-shared/extent_io.c:57:7: warning[unix.Malloc]: Use of memory after it is freed
# 55| while(!list_empty(&fs_info->lru)) {
# 56| eb = list_entry(fs_info->lru.next, struct extent_buffer, lru);
# 57|-> if (eb->refs) {
# 58| /*
# 59| * Reset extent buffer refs to 1, so the
Error: GCC_ANALYZER_WARNING (CWE-127): [#def165]
btrfs-progs-v6.8/kernel-shared/extent_io.c: scope_hint: In function ‘read_raid56’
btrfs-progs-v6.8/kernel-shared/extent_io.c:413:29: warning[-Wanalyzer-out-of-bounds]: heap-based buffer under-read
btrfs-progs-v6.8/kernel-lib/raid56.h:27: included_from: Included from here.
btrfs-progs-v6.8/kernel-shared/extent_io.c:26: included_from: Included from here.
btrfs-progs-v6.8/kernel-lib/bitops.h:20:22: note: in expansion of macro ‘find_first_bit’
btrfs-progs-v6.8/kernel-shared/extent_io.c:400:9: note: in expansion of macro ‘for_each_set_bit’
btrfs-progs-v6.8/kernel-lib/bitops.h: scope_hint: In function ‘read_raid56’
btrfs-progs-v6.8/kernel-lib/bitops.h:20:22: note: in expansion of macro ‘find_first_bit’
btrfs-progs-v6.8/kernel-shared/extent_io.c:400:9: note: in expansion of macro ‘for_each_set_bit’
btrfs-progs-v6.8/kernel-shared/extent_io.c: scope_hint: In function ‘read_raid56’
btrfs-progs-v6.8/kernel-shared/extent_io.c:400:9: note: in expansion of macro ‘for_each_set_bit’
# └─────────────────────────────────────┘
# ^
# 411|
# 412| /* Now copy the data back to original buf */
# 413|-> memcpy(buf, pointers[failed_a] + (logical - full_stripe_start) %
# 414| BTRFS_STRIPE_LEN, len);
# 415| ret = 0;
Error: CLANG_WARNING: [#def166]
btrfs-progs-v6.8/kernel-shared/extent_io.c:419:9: warning[core.NullDereference]: Array access (from variable 'pointers') results in a null pointer dereference
# 417| kfree(failed_stripe_bitmap);
# 418| for (i = 0; i < num_stripes; i++)
# 419|-> kfree(pointers[i]);
# 420| kfree(pointers);
# 421| return ret;
Error: CLANG_WARNING: [#def167]
btrfs-progs-v6.8/kernel-shared/free-space-cache.c:256:18: warning[core.NullDereference]: Access to field 'offset' results in a dereference of a null pointer (loaded from variable 'e')
# 254|
# 255| e = io_ctl->cur;
# 256|-> entry->offset = le64_to_cpu(e->offset);
# 257| entry->bytes = le64_to_cpu(e->bytes);
# 258| *type = e->type;
Error: CLANG_WARNING: [#def168]
btrfs-progs-v6.8/kernel-shared/free-space-cache.c:974:4: warning[deadcode.DeadStores]: Value stored to 'ret' is never read
# 972| BTRFS_EXTENT_DATA_KEY);
# 973| if (ret > 0) {
# 974|-> ret = 0;
# 975| break;
# 976| }
Error: CLANG_WARNING: [#def169]
btrfs-progs-v6.8/kernel-shared/free-space-tree.c:44:16: warning[core.NullDereference]: Access to field 'global_root_id' results in a dereference of a null pointer (loaded from variable 'block_group')
# 42|
# 43| if (btrfs_fs_incompat(fs_info, EXTENT_TREE_V2))
# 44|-> key.offset = block_group->global_root_id;
# 45|
# 46| return btrfs_global_root(fs_info, &key);
Error: CLANG_WARNING: [#def170]
btrfs-progs-v6.8/kernel-shared/inode.c:762:5: warning[deadcode.DeadStores]: Value stored to 'start_found' is never read
# 760| if (!start_found) {
# 761| *objectid = search_start;
# 762|-> start_found = 1;
# 763| goto found;
# 764| }
Error: COMPILER_WARNING: [#def171]
btrfs-progs-v6.8/kernel-shared/print-tree.c: scope_hint: In function ‘bg_flags_to_str’
btrfs-progs-v6.8/kernel-shared/print-tree.c:206:25: warning[-Wstringop-truncation]: ‘strncpy’ specified bound 64 equals destination size
# 206 | strncpy(profile, name, BG_FLAG_STRING_LEN);
# | ^
# 204| */
# 205| if (strncmp(name, "SINGLE", strlen("SINGLE")) != 0)
# 206|-> strncpy(profile, name, BG_FLAG_STRING_LEN);
# 207| }
# 208| if (profile[0]) {
Error: CLANG_WARNING: [#def172]
btrfs-progs-v6.8/kernel-shared/print-tree.c:431:4: warning[deadcode.DeadStores]: Value stored to 'empty' is never read
# 429| if (flags & BTRFS_EXTENT_FLAG_TREE_BLOCK) {
# 430| if (!empty) {
# 431|-> empty = 0;
# 432| strcat(ret, "|");
# 433| }
Error: CLANG_WARNING: [#def173]
btrfs-progs-v6.8/kernel-shared/print-tree.c:1345:9: warning[deadcode.DeadStores]: Value stored to 'tmp' during its initialization is never read
# 1343| printf("\n");
# 1344| if (fs_info && (mode & BTRFS_PRINT_TREE_CSUM_HEADERS)) {
# 1345|-> char *tmp = csum_str;
# 1346| u8 *tree_csum = (u8 *)(eb->data + offsetof(struct btrfs_header, csum));
# 1347|
Error: CLANG_WARNING: [#def174]
btrfs-progs-v6.8/kernel-shared/print-tree.c:1678:5: warning[deadcode.DeadStores]: Value stored to 'ret' is never read
# 1676| goto out;
# 1677| if (ret > 0) {
# 1678|-> ret = 0;
# 1679| break;
# 1680| }
Error: GCC_ANALYZER_WARNING (CWE-476): [#def175]
btrfs-progs-v6.8/kernel-shared/volumes.c: scope_hint: In function ‘btrfs_rmap_block’
btrfs-progs-v6.8/kernel-shared/volumes.c:1933:35: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL ‘buf’
btrfs-progs-v6.8/kernel-shared/volumes.c:19: included_from: Included from here.
btrfs-progs-v6.8/kernel-shared/volumes.c:1894:9: note: in expansion of macro ‘BUG_ON’
btrfs-progs-v6.8/kernel-shared/volumes.c: scope_hint: In function ‘btrfs_rmap_block’
btrfs-progs-v6.8/kernel-shared/volumes.c:1908:15: note: in expansion of macro ‘kzalloc’
# 1931| }
# 1932| if (j == nr)
# 1933|-> buf[nr++] = bytenr;
# 1934| }
# 1935|
Error: GCC_ANALYZER_WARNING (CWE-476): [#def176]
btrfs-progs-v6.8/kernel-shared/volumes.c: scope_hint: In function ‘fill_missing_device’
btrfs-progs-v6.8/kernel-shared/volumes.c:2367:23: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL ‘device’
btrfs-progs-v6.8/kernel-shared/volumes.c:2366:18: note: in expansion of macro ‘kzalloc’
# 2365|
# 2366| device = kzalloc(sizeof(*device), GFP_NOFS);
# 2367|-> device->devid = devid;
# 2368| memcpy(device->uuid, uuid, BTRFS_UUID_SIZE);
# 2369| device->fd = -1;
Error: GCC_ANALYZER_WARNING (CWE-457): [#def177]
btrfs-progs-v6.8/kernel-shared/volumes.c: scope_hint: In function ‘write_raid56_with_parity’
btrfs-progs-v6.8/kernel-shared/volumes.c:2839:32: warning[-Wanalyzer-use-of-uninitialized-value]: use of uninitialized value ‘*<unknown>’
btrfs-progs-v6.8/kernel-shared/volumes.c:2820:15: note: in expansion of macro ‘kmalloc’
btrfs-progs-v6.8/kernel-shared/volumes.c:2800:9: note: in expansion of macro ‘kfree’
btrfs-progs-v6.8/kernel-shared/volumes.c:2845:26: note: in expansion of macro ‘kmalloc’
# 2837| struct extent_buffer *new_eb;
# 2838| if (raid_map[i] < BTRFS_RAID5_P_STRIPE) {
# 2839|-> if (ebs[i]->start != raid_map[i]) {
# 2840| ret = -EINVAL;
# 2841| goto out_free_split;
Error: GCC_ANALYZER_WARNING (CWE-457): [#def178]
btrfs-progs-v6.8/kernel-shared/volumes.c:2887:24: warning[-Wanalyzer-use-of-uninitialized-value]: use of uninitialized value ‘*<unknown>’
btrfs-progs-v6.8/kernel-shared/volumes.c:2820:15: note: in expansion of macro ‘kmalloc’
btrfs-progs-v6.8/kernel-shared/volumes.c:2800:9: note: in expansion of macro ‘kfree’
btrfs-progs-v6.8/kernel-shared/volumes.c:2845:26: note: in expansion of macro ‘kmalloc’
# 2885| out_free_split:
# 2886| for (i = 0; i < multi->num_stripes; i++) {
# 2887|-> if (ebs[i] != eb)
# 2888| kfree(ebs[i]);
# 2889| }
Error: CLANG_WARNING: [#def179]
btrfs-progs-v6.8/kernel-shared/zoned.c:592:12: warning[unix.Malloc]: Potential leak of memory pointed to by 'rep'
# 590| if (rep->nr_zones != 2) {
# 591| if (errno == ENOENT || errno == 0)
# 592|-> return (rw == WRITE ? count : 0);
# 593| error("zoned: failed to read zone info of %u and %u: %m",
# 594| zone_num, zone_num + 1);
Error: CLANG_WARNING: [#def180]
btrfs-progs-v6.8/libbtrfs/send-utils.c:490:10: warning[unix.Malloc]: Potential leak of memory pointed to by 'si'
# 488| si = subvol_uuid_search2(s, root_id, uuid, transid, path, type);
# 489| if (IS_ERR(si))
# 490|-> return NULL;
# 491| return si;
# 492| }
Error: CPPCHECK_WARNING (CWE-401): [#def181]
btrfs-progs-v6.8/libbtrfsutil/qgroup.c:64: error[memleakOnRealloc]: Common realloc mistake: 'tmp' nulled but not freed upon failure
# 62| struct btrfs_qgroup_inherit *tmp = (struct btrfs_qgroup_inherit *)*inherit;
# 63|
# 64|-> tmp = realloc(tmp, sizeof(*tmp) +
# 65| (tmp->num_qgroups + 1) * sizeof(tmp->qgroups[0]));
# 66| if (!tmp)
Error: CLANG_WARNING: [#def182]
btrfs-progs-v6.8/libbtrfsutil/subvolume.c:415:13: warning[core.NullDereference]: Access to field 'id' results in a dereference of a null pointer (loaded from variable 'subvol')
# 413| return BTRFS_UTIL_ERROR_GET_SUBVOL_INFO_FAILED;
# 414|
# 415|-> subvol->id = info.treeid;
# 416| subvol->parent_id = info.parent_id;
# 417| subvol->dir_id = info.dirid;
Error: GCC_ANALYZER_WARNING (CWE-476): [#def183]
btrfs-progs-v6.8/libbtrfsutil/subvolume.c: scope_hint: In function ‘get_subvolume_info_unprivileged’
btrfs-progs-v6.8/libbtrfsutil/subvolume.c:415:20: warning[-Wanalyzer-null-dereference]: dereference of NULL ‘subvol’
btrfs-progs-v6.8/libbtrfsutil/subvolume.c: scope_hint: In function ‘get_subvolume_info_unprivileged’
# 413| return BTRFS_UTIL_ERROR_GET_SUBVOL_INFO_FAILED;
# 414|
# 415|-> subvol->id = info.treeid;
# 416| subvol->parent_id = info.parent_id;
# 417| subvol->dir_id = info.dirid;
Error: CLANG_WARNING: [#def184]
btrfs-progs-v6.8/mkfs/common.c:656:2: warning[deadcode.DeadStores]: Value stored to 'ptr' is never read
# 654| read_extent_buffer(buf, ptr, (unsigned long)chunk, item_size);
# 655| array_size += item_size;
# 656|-> ptr += item_size;
# 657| btrfs_set_super_sys_array_size(&super, array_size);
# 658|
Error: CLANG_WARNING: [#def185]
btrfs-progs-v6.8/mkfs/main.c:282:3: warning[deadcode.DeadStores]: Value stored to 'ret' is never read
# 280| if (ret < 0)
# 281| goto out;
# 282|-> ret = 0;
# 283| btrfs_item_key_to_cpu(path.nodes[0], &found_key, 0);
# 284| UASSERT(btrfs_comp_cpu_keys(&key, &found_key) == 0);
Error: CLANG_WARNING: [#def186]
btrfs-progs-v6.8/mkfs/main.c:1279:5: warning[deadcode.DeadStores]: Value stored to 'ret' is never read
# 1277| /* Deprecated in 4.0 */
# 1278| error("--leafsize has been removed in 6.0, use --nodesize");
# 1279|-> ret = 1;
# 1280| goto error;
# 1281| case 'n':
Error: CLANG_WARNING: [#def187]
btrfs-progs-v6.8/mkfs/main.c:1618:4: warning[deadcode.DeadStores]: Value stored to 'ret' is never read
# 1616| if (ret < 0) {
# 1617| error("unable to stat %s: %m", file);
# 1618|-> ret = -errno;
# 1619| goto error;
# 1620| }
Error: CLANG_WARNING: [#def188]
btrfs-progs-v6.8/mkfs/main.c:1647:3: warning[deadcode.DeadStores]: Value stored to 'dev_block_count' is never read
# 1645| }
# 1646| /* our "device" is the new image file */
# 1647|-> dev_block_count = block_count;
# 1648| close(fd);
# 1649| }
Error: CLANG_WARNING: [#def189]
btrfs-progs-v6.8/mkfs/rootdir.c:628:6: warning[unix.Malloc]: Potential leak of memory pointed to by 'dir_entry'
# 626| if (path_cat_out(tmp, parent_dir_entry->path,
# 627| cur_file->d_name)) {
# 628|-> error("invalid path: %s/%s",
# 629| parent_dir_entry->path,
# 630| cur_file->d_name);
Error: CLANG_WARNING: [#def190]
btrfs-progs-v6.8/mkfs/rootdir.c:924:3: warning[deadcode.DeadStores]: Value stored to 'ret' is never read
# 922| goto err;
# 923| if (ret > 0)
# 924|-> ret = -ENOENT;
# 925| di = btrfs_item_ptr(path.nodes[0], path.slots[0],
# 926| struct btrfs_dev_item);
Error: GCC_ANALYZER_WARNING (CWE-401): [#def191]
btrfs-progs-v6.8/tune/change-csum.c: scope_hint: In function ‘generate_new_data_csums_range’
btrfs-progs-v6.8/tune/change-csum.c:234:24: warning[-Wanalyzer-malloc-leak]: leak of ‘csum_buffer’
btrfs-progs-v6.8/tune/change-csum.c:18: included_from: Included from here.
btrfs-progs-v6.8/tune/change-csum.c: scope_hint: In function ‘generate_new_data_csums_range’
# 232| errno = -ret;
# 233| error("failed to get the last csum item: %m");
# 234|-> return ret;
# 235| }
# 236| csum_buffer = malloc(fs_info->nodesize);
Error: CLANG_WARNING: [#def192]
btrfs-progs-v6.8/tune/change-csum.c:244:9: warning[unix.Malloc]: Potential leak of memory pointed to by 'csum_buffer'
# 242| new_csum_size);
# 243| if (IS_ERR(trans)) {
# 244|-> ret = PTR_ERR(trans);
# 245| errno = -ret;
# 246| error("failed to start transaction: %m");
Error: CLANG_WARNING: [#def193]
btrfs-progs-v6.8/tune/change-csum.c:266:5: warning[deadcode.DeadStores]: Value stored to 'ret' is never read
# 264| ret = btrfs_next_leaf(csum_root, &path);
# 265| if (ret > 0) {
# 266|-> ret = 0;
# 267| btrfs_release_path(&path);
# 268| break;
Scan Properties
analyzer-version-clang | 18.1.3 |
analyzer-version-cppcheck | 2.13.0 |
analyzer-version-gcc | 14.0.1 |
analyzer-version-gcc-analyzer | 14.0.1 |
analyzer-version-shellcheck | 0.10.0 |
enabled-plugins | clang, cppcheck, gcc, shellcheck |
exit-code | 0 |
host | ip-172-16-1-225.us-west-2.compute.internal |
mock-config | fedora-41-x86_64 |
project-name | btrfs-progs-6.8-1.fc41 |
store-results-to | /tmp/tmprngle3ek/btrfs-progs-6.8-1.fc41.tar.xz |
time-created | 2024-04-22 10:49:35 |
time-finished | 2024-04-22 10:52:45 |
tool | csmock |
tool-args | '/usr/bin/csmock' '-r' 'fedora-41-x86_64' '-t' 'cppcheck,gcc,clang,shellcheck' '-o' '/tmp/tmprngle3ek/btrfs-progs-6.8-1.fc41.tar.xz' '--gcc-analyze' '/tmp/tmprngle3ek/btrfs-progs-6.8-1.fc41.src.rpm' |
tool-version | csmock-3.5.3-1.el9 |