* [BUG REPORT] use of unreachable() masks uninitialized variables warnings
@ 2016-02-11 3:13 Jeff Merkey
2016-02-11 14:06 ` Theodore Ts'o
0 siblings, 1 reply; 8+ messages in thread
From: Jeff Merkey @ 2016-02-11 3:13 UTC (permalink / raw)
To: LKML
Hi,
I noticed that the use of the function -- unreachable() -- inside of
the BUG() macro in arch/x86/include/asm/bug.h causes compiler output
to be suspect based on review of assembly output for quite a few
areas.
if as a test, you remove the call to unreachable() in the BUG() macro,
it seems to generate a large number of build warnings about the use of
uninitialized variables that are apparently masked by the compiler
since it believes this code is going to halt, even in the cases where
the BUG() macro is used conditionally, as in an if (condition) then
BUG() (which the compiler does not seem to understand).
This seems to indicate that the use of these built in macros telling
the compiler to create a bunch of infinite jump labels is masking
quite a few bugs lurking around in the regular code since gcc
apparently just throws out the checks for uninitialized variables in
any function if it sees this macro anywhere in the function.
Here are the sources of several bugs I have seen recently in ext4 I am
pretty sure with a null bh. One good check is to set the BUG() macro
NOT TO call unreachable() as a build test since the compiler will
ignore uninitialized variables in a function if someone calls BUG()
even conditionally, and never report them during build.
The following are from v4.4.1 with a BUG() macro with the call to
unreachable() removed:
arch/x86/kernel/apic/x2apic_uv_x.c: In function ‘boot_pnode_to_blade’:
arch/x86/kernel/apic/x2apic_uv_x.c:443:1: warning: control reaches end
of non-void function [-Wreturn-type]
}
^
arch/x86/kernel/apic/x2apic_uv_x.c: In function ‘uv_acpi_madt_oem_check’:
arch/x86/kernel/apic/x2apic_uv_x.c:201:1: warning: control reaches end
of non-void function [-Wreturn-type]
}
^
arch/x86/kvm/x86.c: In function ‘emulator_cmpxchg_emulated’:
arch/x86/kvm/x86.c:4562:5: warning: ‘exchanged’ may be used
uninitialized in this function [-Wmaybe-uninitialized]
if (!exchanged)
^
In file included from kernel/locking/qspinlock.c:470:0:
kernel/locking/qspinlock_paravirt.h: In function ‘pv_unhash’:
kernel/locking/qspinlock_paravirt.h:144:1: warning: control reaches
end of non-void function [-Wreturn-type]
}
^
kernel/locking/qspinlock_paravirt.h: In function ‘pv_hash’:
kernel/locking/qspinlock_paravirt.h:121:1: warning: control reaches
end of non-void function [-Wreturn-type]
}
^
kernel/sched/core.c: In function ‘pick_next_task’:
kernel/sched/core.c:3064:1: warning: control reaches end of non-void
function [-Wreturn-type]
}
^
kernel/seccomp.c: In function ‘seccomp_phase1’:
kernel/seccomp.c:672:1: warning: control reaches end of non-void
function [-Wreturn-type]
}
^
mm/mmap.c: In function ‘vma_adjust’:
mm/mmap.c:661:15: warning: ‘rb_parent’ may be used uninitialized in
this function [-Wmaybe-uninitialized]
__vma_link_rb(mm, vma, rb_link, rb_parent);
^
mm/mmap.c:692:29: note: ‘rb_parent’ was declared here
struct rb_node **rb_link, *rb_parent;
^
mm/mmap.c:661:15: warning: ‘rb_link’ may be used uninitialized in this
function [-Wmaybe-uninitialized]
__vma_link_rb(mm, vma, rb_link, rb_parent);
^
mm/mmap.c:692:19: note: ‘rb_link’ was declared here
struct rb_node **rb_link, *rb_parent;
^
mm/mmap.c:660:17: warning: ‘prev’ may be used uninitialized in this
function [-Wmaybe-uninitialized]
__vma_link_list(mm, vma, prev, rb_parent);
^
mm/mmap.c:691:25: note: ‘prev’ was declared here
struct vm_area_struct *prev;
^
mm/hugetlb.c: In function ‘__vma_reservation_common’:
mm/hugetlb.c:1815:3: warning: ‘ret’ may be used uninitialized in this
function [-Wmaybe-uninitialized]
return ret < 0 ? ret : 0;
^
mm/mempolicy.c: In function ‘mempolicy_slab_node’:
mm/mempolicy.c:1731:1: warning: control reaches end of non-void
function [-Wreturn-type]
}
^
mm/memcontrol.c: In function ‘mem_cgroup_read_u64’:
mm/memcontrol.c:2892:1: warning: control reaches end of non-void
function [-Wreturn-type]
}
^
In file included from mm/memcontrol.c:34:0:
mm/memcontrol.c: In function ‘mem_cgroup_reset’:
include/linux/page_counter.h:49:21: warning: ‘counter’ may be used
uninitialized in this function [-Wmaybe-uninitialized]
counter->watermark = page_counter_read(counter);
^
mm/memcontrol.c:3038:23: note: ‘counter’ was declared here
struct page_counter *counter;
^
mm/memcontrol.c: In function ‘__mem_cgroup_usage_unregister_event’:
mm/memcontrol.c:3511:6: warning: ‘usage’ may be used uninitialized in
this function [-Wmaybe-uninitialized]
if (new->entries[j].threshold <= usage) {
^
mm/memcontrol.c:3506:35: warning: ‘thresholds’ may be used
uninitialized in this function [-Wmaybe-uninitialized]
for (i = 0, j = 0; i < thresholds->primary->size; i++) {
^
mm/memcontrol.c: In function ‘__mem_cgroup_usage_register_event’:
mm/memcontrol.c:3423:6: warning: ‘usage’ may be used uninitialized in
this function [-Wmaybe-uninitialized]
if (new->entries[i].threshold <= usage) {
^
mm/memcontrol.c:3392:16: warning: ‘thresholds’ may be used
uninitialized in this function [-Wmaybe-uninitialized]
if (thresholds->primary)
^
In file included from ./arch/x86/include/asm/atomic.h:4:0,
from include/linux/atomic.h:4,
from include/linux/page_counter.h:4,
from mm/memcontrol.c:34:
mm/memcontrol.c: In function ‘mem_cgroup_read_u64’:
include/linux/compiler.h:207:26: warning: ‘counter’ may be used
uninitialized in this function [-Wmaybe-uninitialized]
case 8: *(__u64 *)res = *(volatile __u64 *)p; break; \
^
mm/memcontrol.c:2858:23: note: ‘counter’ was declared here
struct page_counter *counter;
^
mm/hugetlb_cgroup.c: In function ‘hugetlb_cgroup_read_u64’:
mm/hugetlb_cgroup.c:268:1: warning: control reaches end of non-void
function [-Wreturn-type]
}
^
fs/btrfs/inode.c: In function ‘run_delalloc_nocow’:
fs/btrfs/inode.c:1384:6: warning: ‘extent_end’ may be used
uninitialized in this function [-Wmaybe-uninitialized]
if (extent_end <= start) {
^
In file included from include/linux/sched.h:17:0,
from fs/btrfs/volumes.c:18:
fs/btrfs/volumes.c: In function ‘__btrfs_alloc_chunk’:
include/linux/kernel.h:725:24: warning: ‘max_chunk_size’ may be used
uninitialized in this function [-Wmaybe-uninitialized]
_min1 < _min2 ? _min1 : _min2; })
^
fs/btrfs/volumes.c:4507:6: note: ‘max_chunk_size’ was declared here
u64 max_chunk_size;
^
fs/btrfs/volumes.c:4599:29: warning: ‘max_stripe_size’ may be used
uninitialized in this function [-Wmaybe-uninitialized]
ret = find_free_dev_extent(trans, device,
^
fs/btrfs/delayed-inode.c: In function ‘__btrfs_add_delayed_item’:
fs/btrfs/delayed-inode.c:407:18: warning: ‘root’ may be used
uninitialized in this function [-Wmaybe-uninitialized]
struct rb_root *root;
^
fs/btrfs/backref.c: In function ‘__add_delayed_refs’:
fs/btrfs/backref.c:649:33: warning: ‘sgn’ may be used uninitialized in
this function [-Wmaybe-uninitialized]
*total_refs += (node->ref_mod * sgn);
^
fs/btrfs/acl.c: In function ‘btrfs_get_acl’:
fs/btrfs/acl.c:49:25: warning: ‘name’ may be used uninitialized in
this function [-Wmaybe-uninitialized]
size = __btrfs_getxattr(inode, name, "", 0);
^
fs/ceph/locks.c: In function ‘ceph_lock_wait_for_completion’:
fs/ceph/locks.c:140:40: warning: ‘lock_type’ may be used uninitialized
in this function [-Wmaybe-uninitialized]
intr_req->r_args.filelock_change.rule = lock_type;
^
In file included from fs/ext4/file.c:30:0:
fs/ext4/ext4_jbd2.h: In function ‘ext4_inode_journal_mode’:
fs/ext4/ext4_jbd2.h:409:1: warning: control reaches end of non-void
function [-Wreturn-type]
}
^
In file included from fs/ext4/fsync.c:32:0:
fs/ext4/ext4_jbd2.h: In function ‘ext4_inode_journal_mode’:
fs/ext4/ext4_jbd2.h:409:1: warning: control reaches end of non-void
function [-Wreturn-type]
}
^
In file included from fs/ext4/inode.c:41:0:
fs/ext4/ext4_jbd2.h: In function ‘ext4_inode_journal_mode’:
fs/ext4/ext4_jbd2.h:409:1: warning: control reaches end of non-void
function [-Wreturn-type]
}
^
fs/ext4/inode.c: In function ‘ext4_map_blocks’:
fs/ext4/inode.c:548:5: warning: ‘retval’ may be used uninitialized in
this function [-Wmaybe-uninitialized]
if (retval > 0 && map->m_flags & EXT4_MAP_MAPPED) {
^
In file included from fs/ext4/super.c:48:0:
fs/ext4/ext4_jbd2.h: In function ‘ext4_inode_journal_mode’:
fs/ext4/ext4_jbd2.h:409:1: warning: control reaches end of non-void
function [-Wreturn-type]
}
^
In file included from fs/ext4/extents.c:43:0:
fs/ext4/ext4_jbd2.h: In function ‘ext4_inode_journal_mode’:
fs/ext4/ext4_jbd2.h:409:1: warning: control reaches end of non-void
function [-Wreturn-type]
}
^
fs/ext4/extents.c: In function ‘ext4_ext_put_gap_in_cache’:
fs/ext4/extents.c:2306:14: warning: ‘lblock’ may be used uninitialized
in this function [-Wmaybe-uninitialized]
ext4_lblk_t lblock;
^
fs/ext4/extents.c:2305:14: warning: ‘len’ may be used uninitialized in
this function [-Wmaybe-uninitialized]
ext4_lblk_t len;
^
In file included from fs/ext4/ext4_jbd2.c:5:0:
fs/ext4/ext4_jbd2.h: In function ‘ext4_inode_journal_mode’:
fs/ext4/ext4_jbd2.h:409:1: warning: control reaches end of non-void
function [-Wreturn-type]
}
^
In file included from fs/ext4/mballoc.c:24:0:
fs/ext4/ext4_jbd2.h: In function ‘ext4_inode_journal_mode’:
fs/ext4/ext4_jbd2.h:409:1: warning: control reaches end of non-void
function [-Wreturn-type]
}
^
In file included from fs/ext4/move_extent.c:19:0:
fs/ext4/ext4_jbd2.h: In function ‘ext4_inode_journal_mode’:
fs/ext4/ext4_jbd2.h:409:1: warning: control reaches end of non-void
function [-Wreturn-type]
}
^
In file included from fs/ext4/indirect.c:23:0:
fs/ext4/ext4_jbd2.h: In function ‘ext4_inode_journal_mode’:
fs/ext4/ext4_jbd2.h:409:1: warning: control reaches end of non-void
function [-Wreturn-type]
}
^
In file included from fs/ext4/inline.c:17:0:
fs/ext4/ext4_jbd2.h: In function ‘ext4_inode_journal_mode’:
fs/ext4/ext4_jbd2.h:409:1: warning: control reaches end of non-void
function [-Wreturn-type]
}
^
fs/ext4/acl.c: In function ‘ext4_get_acl’:
fs/ext4/acl.c:160:9: warning: ‘name_index’ may be used uninitialized
in this function [-Wmaybe-uninitialized]
retval = ext4_xattr_get(inode, name_index, "", NULL, 0);
^
fs/nfs/filelayout/filelayout.c: In function ‘filelayout_get_dserver_offset’:
fs/nfs/filelayout/filelayout.c:86:1: warning: control reaches end of
non-void function [-Wreturn-type]
}
^
fs/nfs/flexfilelayout/flexfilelayoutdev.c: In function
‘nfs4_ff_find_or_create_ds_client’:
fs/nfs/flexfilelayout/flexfilelayoutdev.c:493:1: warning: control
reaches end of non-void function [-Wreturn-type]
}
^
In file included from include/linux/sunrpc/svcsock.h:13:0,
from include/linux/sunrpc/svcauth_gss.h:16,
from fs/nfsd/nfs4state.c:42:
include/linux/sunrpc/svc_xprt.h: In function ‘svc_addr_len’:
include/linux/sunrpc/svc_xprt.h:174:1: warning: control reaches end of
non-void function [-Wreturn-type]
}
^
fs/notify/fanotify/fanotify.c: In function ‘fanotify_handle_event’:
fs/notify/fanotify/fanotify.c:143:32: warning: ‘marks_ignored_mask’
may be used uninitialized in this function [-Wmaybe-uninitialized]
!(marks_mask & FS_ISDIR & ~marks_ignored_mask))
^
fs/notify/fanotify/fanotify.c:106:20: note: ‘marks_ignored_mask’ was
declared here
__u32 marks_mask, marks_ignored_mask;
^
fs/notify/fanotify/fanotify.c:143:30: warning: ‘marks_mask’ may be
used uninitialized in this function [-Wmaybe-uninitialized]
!(marks_mask & FS_ISDIR & ~marks_ignored_mask))
^
fs/notify/fanotify/fanotify.c:106:8: note: ‘marks_mask’ was declared here
__u32 marks_mask, marks_ignored_mask;
^
fs/quota/kqid.c: In function ‘qid_eq’:
fs/quota/kqid.c:26:1: warning: control reaches end of non-void
function [-Wreturn-type]
}
^
fs/quota/kqid.c: In function ‘qid_lt’:
fs/quota/kqid.c:52:1: warning: control reaches end of non-void
function [-Wreturn-type]
}
^
fs/quota/kqid.c: In function ‘from_kqid’:
fs/quota/kqid.c:79:1: warning: control reaches end of non-void
function [-Wreturn-type]
}
^
fs/quota/kqid.c: In function ‘from_kqid_munged’:
fs/quota/kqid.c:112:1: warning: control reaches end of non-void
function [-Wreturn-type]
}
^
fs/quota/kqid.c: In function ‘qid_valid’:
fs/quota/kqid.c:131:1: warning: control reaches end of non-void
function [-Wreturn-type]
}
^
fs/udf/inode.c: In function ‘udf_setsize’:
fs/udf/inode.c:641:15: warning: ‘adsize’ may be used uninitialized in
this function [-Wmaybe-uninitialized]
epos.offset -= adsize;
^
fs/udf/inode.c:608:6: note: ‘adsize’ was declared here
int adsize;
^
fs/udf/truncate.c: In function ‘udf_truncate_tail_extent’:
fs/udf/truncate.c:105:16: warning: ‘adsize’ may be used uninitialized
in this function [-Wmaybe-uninitialized]
epos.offset -= adsize;
^
fs/udf/truncate.c: In function ‘udf_truncate_extents’:
fs/udf/truncate.c:229:14: warning: ‘adsize’ may be used uninitialized
in this function [-Wmaybe-uninitialized]
epos.offset -= adsize;
^
fs/xfs/xfs_acl.c: In function ‘xfs_get_acl’:
fs/xfs/xfs_acl.c:156:8: warning: ‘ea_name’ may be used uninitialized
in this function [-Wmaybe-uninitialized]
error = xfs_attr_get(ip, ea_name, (unsigned char *)xfs_acl,
^
fs/posix_acl.c: In function ‘acl_by_type’:
fs/posix_acl.c:34:1: warning: control reaches end of non-void function
[-Wreturn-type]
}
^
In file included from include/linux/async_tx.h:20:0,
from crypto/async_tx/async_pq.c:27:
include/linux/dmaengine.h: In function ‘dma_maxpq’:
include/linux/dmaengine.h:955:1: warning: control reaches end of
non-void function [-Wreturn-type]
}
^
block/cfq-iosched.c: In function ‘cfq_async_queue_prio’:
block/cfq-iosched.c:3775:1: warning: control reaches end of non-void
function [-Wreturn-type]
}
^
drivers/ata/pata_atiixp.c: In function ‘atiixp_set_dmamode’:
drivers/ata/pata_atiixp.c:195:24: warning: ‘wanted_pio’ may be used
uninitialized in this function [-Wmaybe-uninitialized]
atiixp_set_pio_timing(ap, adev, wanted_pio);
^
drivers/gpu/drm/gma500/psb_irq.c: In function ‘psb_pipestat’:
drivers/gpu/drm/gma500/psb_irq.c:47:1: warning: control reaches end of
non-void function [-Wreturn-type]
}
^
drivers/gpu/drm/gma500/psb_irq.c: In function ‘mid_pipe_event’:
drivers/gpu/drm/gma500/psb_irq.c:59:1: warning: control reaches end of
non-void function [-Wreturn-type]
}
^
drivers/gpu/drm/gma500/psb_irq.c: In function ‘mid_pipeconf’:
drivers/gpu/drm/gma500/psb_irq.c:83:1: warning: control reaches end of
non-void function [-Wreturn-type]
}
^
drivers/gpu/drm/i915/i915_sysfs.c: In function ‘gt_rp_mhz_show’:
drivers/gpu/drm/i915/i915_sysfs.c:492:17: warning: ‘val’ may be used
uninitialized in this function [-Wmaybe-uninitialized]
return snprintf(buf, PAGE_SIZE, "%d\n", val);
^
In file included from drivers/gpu/drm/i915/i915_trace.h:10:0,
from drivers/gpu/drm/i915/i915_drv.h:2636,
from drivers/gpu/drm/i915/intel_runtime_pm.c:32:
drivers/gpu/drm/i915/intel_drv.h: In function ‘vlv_dport_to_phy’:
drivers/gpu/drm/i915/intel_drv.h:837:1: warning: control reaches end
of non-void function [-Wreturn-type]
}
^
drivers/gpu/drm/i915/intel_drv.h: In function ‘vlv_dport_to_channel’:
drivers/gpu/drm/i915/intel_drv.h:823:1: warning: control reaches end
of non-void function [-Wreturn-type]
}
^
drivers/gpu/drm/i915/i915_cmd_parser.c: In function ‘i915_cmd_parser_init_ring’:
drivers/gpu/drm/i915/i915_cmd_parser.c:563:2: warning:
‘cmd_table_count’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
for (i = 0; i < cmd_table_count; i++) {
^
drivers/gpu/drm/i915/i915_cmd_parser.c:691:6: note: ‘cmd_table_count’
was declared here
int cmd_table_count;
^
drivers/gpu/drm/i915/i915_cmd_parser.c:690:35: warning: ‘cmd_tables’
may be used uninitialized in this function [-Wmaybe-uninitialized]
const struct drm_i915_cmd_table *cmd_tables;
^
In file included from include/linux/list.h:8:0,
from include/linux/agp_backend.h:33,
from include/drm/drmP.h:35,
from drivers/gpu/drm/i915/i915_gem_context.c:88:
drivers/gpu/drm/i915/i915_gem_context.c: In function ‘i915_gem_context_init’:
include/linux/kernel.h:63:30: warning: ‘ret’ may be used uninitialized
in this function [-Wmaybe-uninitialized]
#define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1)
^
drivers/gpu/drm/i915/i915_gem_context.c:111:6: note: ‘ret’ was declared here
int ret;
^
In file included from drivers/gpu/drm/i915/intel_display.c:36:0:
drivers/gpu/drm/i915/intel_drv.h: In function ‘vlv_pipe_to_channel’:
drivers/gpu/drm/i915/intel_drv.h:851:1: warning: control reaches end
of non-void function [-Wreturn-type]
}
^
drivers/gpu/drm/i915/intel_display.c: In function ‘ironlake_check_fdi_lanes’:
drivers/gpu/drm/i915/intel_display.c:6564:1: warning: control reaches
end of non-void function [-Wreturn-type]
}
^
drivers/gpu/drm/i915/intel_display.c: In function ‘vlv_wait_port_ready’:
drivers/gpu/drm/i915/intel_display.c:1841:6: warning: ‘dpll_reg’ may
be used uninitialized in this function [-Wmaybe-uninitialized]
int dpll_reg;
^
drivers/gpu/drm/i915/intel_display.c:1861:36: warning: ‘port_mask’ may
be used uninitialized in this function [-Wmaybe-uninitialized]
if (wait_for((I915_READ(dpll_reg) & port_mask) == expected_mask, 1000))
^
drivers/gpu/drm/i915/intel_ddi.c: In function ‘intel_prepare_ddi’:
drivers/gpu/drm/i915/intel_ddi.c:441:30: warning: ‘ddi_translations’
may be used uninitialized in this function [-Wmaybe-uninitialized]
const struct ddi_buf_trans *ddi_translations;
^
drivers/gpu/drm/i915/intel_ddi.c:435:6: warning: ‘size’ may be used
uninitialized in this function [-Wmaybe-uninitialized]
size;
^
In file included from drivers/gpu/drm/i915/intel_dp.c:38:0:
drivers/gpu/drm/i915/intel_drv.h: In function ‘vlv_pipe_to_channel’:
drivers/gpu/drm/i915/intel_drv.h:851:1: warning: control reaches end
of non-void function [-Wreturn-type]
}
^
drivers/gpu/drm/i915/intel_drv.h: In function ‘vlv_dport_to_channel’:
drivers/gpu/drm/i915/intel_drv.h:823:1: warning: control reaches end
of non-void function [-Wreturn-type]
}
^
In file included from drivers/gpu/drm/i915/intel_hdmi.c:37:0:
drivers/gpu/drm/i915/intel_drv.h: In function ‘vlv_dport_to_channel’:
drivers/gpu/drm/i915/intel_drv.h:823:1: warning: control reaches end
of non-void function [-Wreturn-type]
}
^
drivers/gpu/drm/nouveau/nvkm/subdev/clk/nv50.c: In function ‘read_pll_ref’:
drivers/gpu/drm/nouveau/nvkm/subdev/clk/nv50.c:118:5: warning: ‘M’ may
be used uninitialized in this function [-Wmaybe-uninitialized]
if (M)
^
drivers/gpu/drm/nouveau/nvkm/subdev/clk/nv50.c:58:12: note: ‘M’ was
declared here
int P, N, M, id;
^
drivers/gpu/drm/nouveau/nvkm/subdev/clk/nv50.c:119:15: warning: ‘N’
may be used uninitialized in this function [-Wmaybe-uninitialized]
return (ref * N / M) >> P;
^
drivers/gpu/drm/nouveau/nvkm/subdev/clk/nv50.c:58:9: note: ‘N’ was declared here
int P, N, M, id;
^
drivers/gpu/drm/nouveau/nvkm/subdev/clk/nv50.c:119:3: warning: ‘P’ may
be used uninitialized in this function [-Wmaybe-uninitialized]
return (ref * N / M) >> P;
^
drivers/gpu/drm/nouveau/nvkm/subdev/clk/nv50.c:58:6: note: ‘P’ was declared here
int P, N, M, id;
^
drivers/gpu/drm/radeon/ni.c: In function ‘ni_init_microcode’:
drivers/gpu/drm/radeon/ni.c:812:6: warning: ‘mc_req_size’ may be used
uninitialized in this function [-Wmaybe-uninitialized]
if (rdev->mc_fw->size != mc_req_size) {
^
drivers/gpu/drm/radeon/ni.c:799:5: warning: ‘rlc_req_size’ may be used
uninitialized in this function [-Wmaybe-uninitialized]
if (rdev->rlc_fw->size != rlc_req_size) {
^
drivers/gpu/drm/radeon/ni.c:788:5: warning: ‘me_req_size’ may be used
uninitialized in this function [-Wmaybe-uninitialized]
if (rdev->me_fw->size != me_req_size) {
^
drivers/gpu/drm/radeon/ni.c:776:5: warning: ‘pfp_req_size’ may be used
uninitialized in this function [-Wmaybe-uninitialized]
if (rdev->pfp_fw->size != pfp_req_size) {
^
drivers/gpu/drm/radeon/ni.c:795:10: warning: ‘rlc_chip_name’ may be
used uninitialized in this function [-Wmaybe-uninitialized]
snprintf(fw_name, sizeof(fw_name), "radeon/%s_rlc.bin", rlc_chip_name);
^
drivers/gpu/drm/radeon/ni.c:821:11: warning: ‘chip_name’ may be used
uninitialized in this function [-Wmaybe-uninitialized]
snprintf(fw_name, sizeof(fw_name), "radeon/%s_smc.bin", chip_name);
^
drivers/gpu/drm/radeon/si.c: In function ‘si_init’:
drivers/gpu/drm/radeon/si.c:1830:42: warning: ‘mc2_req_size’ may be
used uninitialized in this function [-Wmaybe-uninitialized]
if ((rdev->mc_fw->size != mc_req_size) &&
^
drivers/gpu/drm/radeon/si.c:1652:23: note: ‘mc2_req_size’ was declared here
size_t smc_req_size, mc2_req_size;
^
drivers/gpu/drm/radeon/si.c:1862:13: warning: ‘smc_req_size’ may be
used uninitialized in this function [-Wmaybe-uninitialized]
} else if (rdev->smc_fw->size != smc_req_size) {
^
drivers/gpu/drm/radeon/si.c:1652:9: note: ‘smc_req_size’ was declared here
size_t smc_req_size, mc2_req_size;
^
drivers/gpu/drm/radeon/si.c:1830:6: warning: ‘mc_req_size’ may be used
uninitialized in this function [-Wmaybe-uninitialized]
if ((rdev->mc_fw->size != mc_req_size) &&
^
drivers/gpu/drm/radeon/si.c:1651:63: note: ‘mc_req_size’ was declared here
size_t pfp_req_size, me_req_size, ce_req_size, rlc_req_size, mc_req_size;
^
drivers/gpu/drm/radeon/si.c:1850:10: warning: ‘new_chip_name’ may be
used uninitialized in this function [-Wmaybe-uninitialized]
snprintf(fw_name, sizeof(fw_name), "radeon/%s_smc.bin", new_chip_name);
^
drivers/gpu/drm/radeon/si.c:1650:14: note: ‘new_chip_name’ was declared here
const char *new_chip_name;
^
drivers/gpu/drm/radeon/si.c:1853:11: warning: ‘chip_name’ may be used
uninitialized in this function [-Wmaybe-uninitialized]
snprintf(fw_name, sizeof(fw_name), "radeon/%s_smc.bin", chip_name);
^
drivers/gpu/drm/radeon/si.c:1649:14: note: ‘chip_name’ was declared here
const char *chip_name;
^
drivers/gpu/drm/radeon/cik.c: In function ‘cik_init_microcode’:
drivers/gpu/drm/radeon/cik.c:2295:12: warning: ‘num_fw’ may be used
uninitialized in this function [-Wmaybe-uninitialized]
} else if (new_fw < num_fw) {
^
drivers/gpu/drm/radeon/cik.c:2186:6: warning: ‘rlc_req_size’ may be
used uninitialized in this function [-Wmaybe-uninitialized]
if (rdev->rlc_fw->size != rlc_req_size) {
^
drivers/gpu/drm/radeon/cik.c:2262:11: warning: ‘new_chip_name’ may be
used uninitialized in this function [-Wmaybe-uninitialized]
snprintf(fw_name, sizeof(fw_name), "radeon/%s_smc.bin", new_chip_name);
^
drivers/gpu/drm/radeon/cik.c:2265:12: warning: ‘chip_name’ may be used
uninitialized in this function [-Wmaybe-uninitialized]
snprintf(fw_name, sizeof(fw_name), "radeon/%s_smc.bin", chip_name);
^
drivers/gpu/drm/radeon/rv770_smc.c: In function ‘rv770_load_smc_ucode’:
drivers/gpu/drm/radeon/rv770_smc.c:489:6: warning: ‘ucode_size’ may be
used uninitialized in this function [-Wmaybe-uninitialized]
u16 ucode_size;
^
drivers/gpu/drm/radeon/rv770_smc.c:384:70: warning: ‘int_vect’ may be
used uninitialized in this function [-Wmaybe-uninitialized]
tmp = (src[i] << 24) | (src[i + 1] << 16) | (src[i + 2] << 8) | src[i + 3];
^
drivers/gpu/drm/radeon/rv770_smc.c:484:12: note: ‘int_vect’ was declared here
const u8 *int_vect;
^
drivers/gpu/drm/radeon/si_smc.c: In function ‘si_load_smc_ucode’:
drivers/gpu/drm/radeon/si_smc.c:215:6: warning: ‘ucode_size’ may be
used uninitialized in this function [-Wmaybe-uninitialized]
u32 ucode_size;
^
drivers/gpu/drm/drm_crtc.c: In function ‘drm_crtc_index’:
drivers/gpu/drm/drm_crtc.c:755:1: warning: control reaches end of
non-void function [-Wreturn-type]
}
^
drivers/gpu/drm/drm_crtc.c: In function ‘drm_connector_index’:
drivers/gpu/drm/drm_crtc.c:1007:1: warning: control reaches end of
non-void function [-Wreturn-type]
}
^
drivers/gpu/drm/drm_crtc.c: In function ‘drm_plane_index’:
drivers/gpu/drm/drm_crtc.c:1299:1: warning: control reaches end of
non-void function [-Wreturn-type]
}
^
drivers/iommu/dmar.c: In function ‘dmar_msi_reg’:
drivers/iommu/dmar.c:1510:1: warning: control reaches end of non-void
function [-Wreturn-type]
}
^
drivers/md/raid0.c: In function ‘find_zone’:
drivers/md/raid0.c:298:1: warning: control reaches end of non-void
function [-Wreturn-type]
}
^
CC [M] drivers/md/raid1.o
CC [M] drivers/md/raid10.o
CC [M] drivers/md/raid5.o
In file included from ./arch/x86/include/asm/bug.h:48:0,
from include/linux/bug.h:4,
from include/linux/thread_info.h:11,
from ./arch/x86/include/asm/preempt.h:6,
from include/linux/preempt.h:59,
from include/linux/spinlock.h:50,
from include/linux/seqlock.h:35,
from include/linux/time.h:5,
from include/uapi/linux/timex.h:56,
from include/linux/timex.h:56,
from include/linux/sched.h:19,
from include/linux/blkdev.h:4,
from drivers/md/raid5.c:46:
drivers/md/raid5.c: In function ‘raid_run_ops’:
include/asm-generic/bug.h:55:35: warning: ‘target’ may be used
uninitialized in this function [-Wmaybe-uninitialized]
#define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
^
drivers/md/raid5.c:1383:6: note: ‘target’ was declared here
int target;
^
drivers/media/common/saa7146/saa7146_fops.c: In function ‘fops_write’:
drivers/media/common/saa7146/saa7146_fops.c:425:1: warning: control
reaches end of non-void function [-Wreturn-type]
}
^
drivers/media/common/saa7146/saa7146_fops.c: In function ‘fops_read’:
drivers/media/common/saa7146/saa7146_fops.c:402:1: warning: control
reaches end of non-void function [-Wreturn-type]
}
^
drivers/media/common/saa7146/saa7146_fops.c: In function ‘fops_mmap’:
drivers/media/common/saa7146/saa7146_fops.c:318:6: warning: ‘q’ may be
used uninitialized in this function [-Wmaybe-uninitialized]
res = videobuf_mmap_mapper(q, vma);
^
drivers/media/firewire/firedtv-avc.c: In function ‘avc_tuner_dsd’:
drivers/media/firewire/firedtv-avc.c:591:6: warning: ‘pos’ may be used
uninitialized in this function [-Wmaybe-uninitialized]
int pos, ret;
^
drivers/media/pci/pt1/va1j5jf8007s.c: In function ‘va1j5jf8007s_read_status’:
drivers/media/pci/pt1/va1j5jf8007s.c:143:1: warning: control reaches
end of non-void function [-Wreturn-type]
}
^
drivers/media/pci/pt1/va1j5jf8007s.c: In function ‘va1j5jf8007s_tune’:
drivers/media/pci/pt1/va1j5jf8007s.c:508:1: warning: control reaches
end of non-void function [-Wreturn-type]
}
^
CC [M] drivers/media/pci/pt1/va1j5jf8007t.o
drivers/media/pci/pt1/va1j5jf8007t.c: In function ‘va1j5jf8007t_read_status’:
drivers/media/pci/pt1/va1j5jf8007t.c:127:1: warning: control reaches
end of non-void function [-Wreturn-type]
}
^
drivers/media/pci/pt1/va1j5jf8007t.c: In function ‘va1j5jf8007t_tune’:
drivers/media/pci/pt1/va1j5jf8007t.c:354:1: warning: control reaches
end of non-void function [-Wreturn-type]
}
^
drivers/media/pci/saa7164/saa7164-encoder.c: In function ‘saa7164_s_frequency’:
drivers/media/pci/saa7164/saa7164-encoder.c:403:5: warning: ‘tsport’
may be used uninitialized in this function [-Wmaybe-uninitialized]
fe = tsport->dvb.frontend;
^
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [BUG REPORT] use of unreachable() masks uninitialized variables warnings
2016-02-11 3:13 [BUG REPORT] use of unreachable() masks uninitialized variables warnings Jeff Merkey
@ 2016-02-11 14:06 ` Theodore Ts'o
2016-02-11 18:12 ` Jeff Merkey
0 siblings, 1 reply; 8+ messages in thread
From: Theodore Ts'o @ 2016-02-11 14:06 UTC (permalink / raw)
To: Jeff Merkey; +Cc: LKML
On Wed, Feb 10, 2016 at 08:13:09PM -0700, Jeff Merkey wrote:
> Here are the sources of several bugs I have seen recently in ext4 I am
> pretty sure with a null bh. One good check is to set the BUG() macro
> NOT TO call unreachable() as a build test since the compiler will
> ignore uninitialized variables in a function if someone calls BUG()
> even conditionally, and never report them during build.
>
> The following are from v4.4.1 with a BUG() macro with the call to
> unreachable() removed:
I checked all of the fs/ext4 warnings you listed and they are all
false positives.
> In file included from fs/ext4/file.c:30:0:
> fs/ext4/ext4_jbd2.h: In function ‘ext4_inode_journal_mode’:
> fs/ext4/ext4_jbd2.h:409:1: warning: control reaches end of non-void
> function [-Wreturn-type]
> }
This is from a:
if (foo) {
...
return foobie;
} else if (bar) {
...
return barbie;
} else {
BUG();
}
construct.
> fs/ext4/inode.c: In function ‘ext4_map_blocks’:
> fs/ext4/inode.c:548:5: warning: ‘retval’ may be used uninitialized in
> this function [-Wmaybe-uninitialized]
> if (retval > 0 && map->m_flags & EXT4_MAP_MAPPED) {
> ^
> fs/ext4/extents.c:2305:14: warning: ‘len’ may be used uninitialized in
> this function [-Wmaybe-uninitialized]
> ext4_lblk_t len;
> ^
All of the may be used uninitialized warnings are from a:
if (foo) {
...
retval = xxx;
} else if (bar) {
...
retval = yyy;
} else {
BUG();
}
construct.
It may be that there are some false warnings, but they certainly weren't
from warnings you've listed from ext4.
Cheers,
- Ted
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [BUG REPORT] use of unreachable() masks uninitialized variables warnings
2016-02-11 14:06 ` Theodore Ts'o
@ 2016-02-11 18:12 ` Jeff Merkey
2016-02-12 2:41 ` Theodore Ts'o
0 siblings, 1 reply; 8+ messages in thread
From: Jeff Merkey @ 2016-02-11 18:12 UTC (permalink / raw)
To: Theodore Ts'o, Jeff Merkey, LKML
On 2/11/16, Theodore Ts'o <tytso@mit.edu> wrote:
> On Wed, Feb 10, 2016 at 08:13:09PM -0700, Jeff Merkey wrote:
>> Here are the sources of several bugs I have seen recently in ext4 I am
>> pretty sure with a null bh. One good check is to set the BUG() macro
>> NOT TO call unreachable() as a build test since the compiler will
>> ignore uninitialized variables in a function if someone calls BUG()
>> even conditionally, and never report them during build.
>>
>> The following are from v4.4.1 with a BUG() macro with the call to
>> unreachable() removed:
>
> I checked all of the fs/ext4 warnings you listed and they are all
> false positives.
>
>> In file included from fs/ext4/file.c:30:0:
>> fs/ext4/ext4_jbd2.h: In function ‘ext4_inode_journal_mode’:
>> fs/ext4/ext4_jbd2.h:409:1: warning: control reaches end of non-void
>> function [-Wreturn-type]
>> }
>
> This is from a:
>
> if (foo) {
> ...
> return foobie;
> } else if (bar) {
> ...
> return barbie;
> } else {
> BUG();
> }
>
> construct.
>
>> fs/ext4/inode.c: In function ‘ext4_map_blocks’:
>> fs/ext4/inode.c:548:5: warning: ‘retval’ may be used uninitialized in
>> this function [-Wmaybe-uninitialized]
>> if (retval > 0 && map->m_flags & EXT4_MAP_MAPPED) {
>> ^
>> fs/ext4/extents.c:2305:14: warning: ‘len’ may be used uninitialized in
>> this function [-Wmaybe-uninitialized]
>> ext4_lblk_t len;
>> ^
>
> All of the may be used uninitialized warnings are from a:
>
> if (foo) {
> ...
> retval = xxx;
> } else if (bar) {
> ...
> retval = yyy;
> } else {
> BUG();
> }
>
> construct.
>
> It may be that there are some false warnings, but they certainly weren't
> from warnings you've listed from ext4.
>
> Cheers,
>
> - Ted
>
Hi Ted,
That's good to know, they could be false positives, but it was kind of
wierd behavior caused by that macro.
Jeff
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [BUG REPORT] use of unreachable() masks uninitialized variables warnings
2016-02-11 18:12 ` Jeff Merkey
@ 2016-02-12 2:41 ` Theodore Ts'o
2016-02-12 4:18 ` Jeff Merkey
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Theodore Ts'o @ 2016-02-12 2:41 UTC (permalink / raw)
To: Jeff Merkey; +Cc: LKML
On Thu, Feb 11, 2016 at 11:12:12AM -0700, Jeff Merkey wrote:
>
> That's good to know, they could be false positives, but it was kind of
> wierd behavior caused by that macro.
If it is true, it sounds more like a compiler bug to me. Any
statements a BUG() call are unreachable. If the compiler assumes that
in the case of:
if (a)
BUG();
printf("foo bar\n");
That the printf is not reachable, that's a compiler bug. And not a
problem in the BUG() macro.
It might be that it's worthwhile to use other static code analysis
tools. Many people will look at warnings from Coverity and clang to
find potential problems, since these tend to find more warnings than
just using gcc. The problem with some of these, including Coverity,
is that they can be __too__ noisy, and if 90% of the warnings are
false positives, most people won't take the time to weed out several
dozen bogus warnings to find the one good one.
In your case, for example, I looked through several dozen warnings,
and they were ***all*** bogus. Keep in mind that this might make me
less inclined to pay attention to complaints from you in the future.
The story of the buy who cried wolf too often comes to mind.
Perhaps you could actually take a close look at the warnings, before
you fire off an e-mail? If at least one of the warnings were valid
and pointed at an actual bug, it wouldn't have been a complete waste
of my time....
Best regards,
- Ted
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [BUG REPORT] use of unreachable() masks uninitialized variables warnings
2016-02-12 2:41 ` Theodore Ts'o
@ 2016-02-12 4:18 ` Jeff Merkey
2016-02-12 4:28 ` Jeff Merkey
2016-02-12 4:58 ` Jeff Merkey
2 siblings, 0 replies; 8+ messages in thread
From: Jeff Merkey @ 2016-02-12 4:18 UTC (permalink / raw)
To: Theodore Ts'o, Jeff Merkey, LKML
On 2/11/16, Theodore Ts'o <tytso@mit.edu> wrote:
> On Thu, Feb 11, 2016 at 11:12:12AM -0700, Jeff Merkey wrote:
>>
>> That's good to know, they could be false positives, but it was kind of
>> wierd behavior caused by that macro.
>
> If it is true, it sounds more like a compiler bug to me. Any
> statements a BUG() call are unreachable. If the compiler assumes that
> in the case of:
>
> if (a)
> BUG();
> printf("foo bar\n");
>
> That the printf is not reachable, that's a compiler bug. And not a
> problem in the BUG() macro.
>
> It might be that it's worthwhile to use other static code analysis
> tools. Many people will look at warnings from Coverity and clang to
> find potential problems, since these tend to find more warnings than
> just using gcc. The problem with some of these, including Coverity,
> is that they can be __too__ noisy, and if 90% of the warnings are
> false positives, most people won't take the time to weed out several
> dozen bogus warnings to find the one good one.
>
> In your case, for example, I looked through several dozen warnings,
> and they were ***all*** bogus. Keep in mind that this might make me
> less inclined to pay attention to complaints from you in the future.
> The story of the buy who cried wolf too often comes to mind.
>
> Perhaps you could actually take a close look at the warnings, before
> you fire off an e-mail? If at least one of the warnings were valid
> and pointed at an actual bug, it wouldn't have been a complete waste
> of my time....
>
> Best regards,
>
> - Ted
>
Well, it's nice to know I wasn't imagining what I was seeing. It
wasn't a complete waste of my time or yours since it revealed a
problem with gcc issuing warnings. Not all of them were bogus BTW,
just inert would be better word. I noticed it while enabling the
ability of the BUG() macro to emit an int3 instead of a ud2
instruction.
Jeff
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [BUG REPORT] use of unreachable() masks uninitialized variables warnings
2016-02-12 2:41 ` Theodore Ts'o
2016-02-12 4:18 ` Jeff Merkey
@ 2016-02-12 4:28 ` Jeff Merkey
2016-02-12 4:41 ` Jeff Merkey
2016-02-12 4:58 ` Jeff Merkey
2 siblings, 1 reply; 8+ messages in thread
From: Jeff Merkey @ 2016-02-12 4:28 UTC (permalink / raw)
To: Theodore Ts'o, Jeff Merkey, LKML
> In your case, for example, I looked through several dozen warnings,
> and they were ***all*** bogus. Keep in mind that this might make me
> less inclined to pay attention to complaints from you in the future.
> The story of the buy who cried wolf too often comes to mind.
>
> Perhaps you could actually take a close look at the warnings, before
> you fire off an e-mail? If at least one of the warnings were valid
> and pointed at an actual bug, it wouldn't have been a complete waste
> of my time....
>
I did take a close look at some of them (I reviewed them in assembler
-- probably a closer look than you gave them) and it was somewhat
confusing since the compiler was outputing jmp labels in the wrong
places in the code after I removed the calls to unreachable().
Ted, that's the problem with sitting around looking at C code all day
trying to find bugs created by the linux macros with assembler output
that does not map precisely to the C code. I discovered this grepping
around in the assembler output of these macro H libs.
If you like I can go over all the garbage assembler this gcc issue
generates around these BUG() macros with calls to unreachable which is
why I raised the issue.
Jeff
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [BUG REPORT] use of unreachable() masks uninitialized variables warnings
2016-02-12 4:28 ` Jeff Merkey
@ 2016-02-12 4:41 ` Jeff Merkey
0 siblings, 0 replies; 8+ messages in thread
From: Jeff Merkey @ 2016-02-12 4:41 UTC (permalink / raw)
To: Theodore Ts'o, Jeff Merkey, LKML
On 2/11/16, Jeff Merkey <linux.mdb@gmail.com> wrote:
>> In your case, for example, I looked through several dozen warnings,
>> and they were ***all*** bogus. Keep in mind that this might make me
>> less inclined to pay attention to complaints from you in the future.
>> The story of the buy who cried wolf too often comes to mind.
>>
>> Perhaps you could actually take a close look at the warnings, before
>> you fire off an e-mail? If at least one of the warnings were valid
>> and pointed at an actual bug, it wouldn't have been a complete waste
>> of my time....
>>
>
> I did take a close look at some of them (I reviewed them in assembler
> -- probably a closer look than you gave them) and it was somewhat
> confusing since the compiler was outputing jmp labels in the wrong
> places in the code after I removed the calls to unreachable().
>
> Ted, that's the problem with sitting around looking at C code all day
> trying to find bugs created by the linux macros with assembler output
> that does not map precisely to the C code. I discovered this grepping
> around in the assembler output of these macro H libs.
>
In other words folks who sit around staring at C code all day looking
for bugs instead of looking at what the compiler output in assembler
are not going to have a clue as to what is busted in their C code. I
worked on a bug for days with tglx that turned out to be a stupid
signed variable declaration outputing a sar instruction instead of a
shr. 6 years it was in linux and all the code reviews failed to catch
it. An assembly language debugger went right to it and it was nailed
shortly thereafter. Of course I had to endure lashing comments from
several folks who were in denial mode and wouldn't accept a simple
patch to just fix the damn thing -- finally someone reported it on
sparc and it got fixed -- amazing.
Jeff
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [BUG REPORT] use of unreachable() masks uninitialized variables warnings
2016-02-12 2:41 ` Theodore Ts'o
2016-02-12 4:18 ` Jeff Merkey
2016-02-12 4:28 ` Jeff Merkey
@ 2016-02-12 4:58 ` Jeff Merkey
2 siblings, 0 replies; 8+ messages in thread
From: Jeff Merkey @ 2016-02-12 4:58 UTC (permalink / raw)
To: Theodore Ts'o, Jeff Merkey, LKML
On 2/11/16, Theodore Ts'o <tytso@mit.edu> wrote:
> On Thu, Feb 11, 2016 at 11:12:12AM -0700, Jeff Merkey wrote:
>>
>> That's good to know, they could be false positives, but it was kind of
>> wierd behavior caused by that macro.
>
> If it is true, it sounds more like a compiler bug to me. Any
> statements a BUG() call are unreachable. If the compiler assumes that
> in the case of:
>
> if (a)
> BUG();
> printf("foo bar\n");
>
> That the printf is not reachable, that's a compiler bug. And not a
> problem in the BUG() macro.
>
> It might be that it's worthwhile to use other static code analysis
> tools. Many people will look at warnings from Coverity and clang to
> find potential problems, since these tend to find more warnings than
> just using gcc. The problem with some of these, including Coverity,
> is that they can be __too__ noisy, and if 90% of the warnings are
> false positives, most people won't take the time to weed out several
> dozen bogus warnings to find the one good one.
>
Did you remove the calls to unreachable() before you did the build?
Remove the call to that function from the BUG() macro, then do a
build, and tell me I am seeing things.
Jeff
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2016-02-12 4:58 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-11 3:13 [BUG REPORT] use of unreachable() masks uninitialized variables warnings Jeff Merkey
2016-02-11 14:06 ` Theodore Ts'o
2016-02-11 18:12 ` Jeff Merkey
2016-02-12 2:41 ` Theodore Ts'o
2016-02-12 4:18 ` Jeff Merkey
2016-02-12 4:28 ` Jeff Merkey
2016-02-12 4:41 ` Jeff Merkey
2016-02-12 4:58 ` Jeff Merkey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).