[Bug 1926995] [NEW] hw/remote/mpqemu-link.c:221: bad error checking ?

2021-05-03 Thread dcb
Public bug reported: hw/remote/mpqemu-link.c:221:36: warning: logical ‘and’ of mutually exclusive tests is always false [-Wlogical-op] Source code is if (msg->cmd >= MPQEMU_CMD_MAX && msg->cmd < 0) { return false; } Maybe better code: if (msg->cmd >= MPQEMU_CMD_MAX || msg->cm

[Bug 1885719] Re: qemu/target/nios2/helper.c:261:20: style:inconclusive: Found duplicate branches for 'if' and 'else'

2020-07-01 Thread dcb
>Which version of QEMU did you use here? git trunk. I have no idea why Richard's patch isn't in my current version and I am disinclined to find out why. Any further work by me on qemu looks somewhat doubtful. Have fun ! -- You received this bug notification because you are a member of qemu- dev

[Bug 1885720] [NEW] qemu/migration/postcopy-ram.c:387: bad return expression ?

2020-06-30 Thread dcb
Public bug reported: qemu/migration/postcopy-ram.c:387:9: style: Non-boolean value returned from function returning bool [returnNonBoolInBooleanFunction] Source code is return -1; but bool postcopy_ram_supported_by_host( ** Affects: qemu Importance: Undecided Status: New

[Bug 1885719] [NEW] qemu/target/nios2/helper.c:261:20: style:inconclusive: Found duplicate branches for 'if' and 'else'

2020-06-30 Thread dcb
Public bug reported: Source code is } else if (address >= 0x8000) { /* Kernel virtual page */ return cpu_nios2_handle_virtual_page(cs, address, rw, mmu_idx); } else { /* User virtual page */ return cpu_nio

[Bug 1885718] [NEW] qemu/target/mips/op_helper.c:943:5: style:inconclusive: Found duplicate branches for 'if' and 'else'

2020-06-30 Thread dcb
Public bug reported: Source code is if (other_tc == other->current_tc) { tccause = other->CP0_Cause; } else { tccause = other->CP0_Cause; } ** Affects: qemu Importance: Undecided Status: New -- You received this bug notification because you are a membe

[Bug 1856706] [NEW] target/mips/op_helper.c:971:duplicated branches ?

2019-12-17 Thread dcb
Public bug reported: qemu-4.2.0/target/mips/op_helper.c:971:8: warning: this condition has identical branches [-Wduplicated-branches] Source code is if (other_tc == other->current_tc) { tccause = other->CP0_Cause; } else { tccause = other->CP0_Cause; } Possible cut'n'

[Bug 1856549] Re: qemu-4.2.0/hw/misc/mac_via.c: 2 * bad test ?

2019-12-16 Thread dcb
gcc compiler flag -Wduplicated-cond will catch this kind of problem. You might want to switch it on in your builds. It has been available for over a year. -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bug

[Bug 1856549] [NEW] qemu-4.2.0/hw/misc/mac_via.c: 2 * bad test ?

2019-12-16 Thread dcb
Public bug reported: 1. qemu-4.2.0/hw/misc/mac_via.c:417:27: style: Expression is always false because 'else if' condition matches previous condition at line 412. [multiCondition] } else if ((m->data_out & 0xf3) == 0xa1) { ... } else if ((m->data_out & 0xf3) == 0x

[Qemu-devel] [Bug 1840646] [NEW] qemu-4.1.0/roms/SLOF/lib/libnet/ping.c:122: logical fault

2019-08-19 Thread dcb
Public bug reported: qemu-4.1.0/roms/SLOF/lib/libnet/ping.c:122:16: warning: Logical conjunction always evaluates to false: alen <= 0 && alen >= sizeof(args) - 1. [incorrectLogicOperator] Source code is if (alen <= 0 && alen >= sizeof(args) - 1) { Maybe better code: if (alen <= 0 || alen

[Qemu-devel] [Bug 1840648] [NEW] qemu-4.1.0/roms/edk2/MdeModulePkg/Universal/Disk/UdfDxe/FileName.c:161: logical fault ?

2019-08-19 Thread dcb
Public bug reported: qemu-4.1.0/roms/edk2/MdeModulePkg/Universal/Disk/UdfDxe/FileName.c:161:71: warning: Logical disjunction always evaluates to true: EXPR != '\\' || EXPR != '\0'. [incorrectLogicOperator] Source code is if ((*(FileName - 1) != L'\\') && ((*(FileName + 2) != L'\\') ||

[Qemu-devel] [Bug 1813460] Re: qemu/target/arm/translate-a64.c:2039: bad test ?

2019-01-27 Thread dcb
Maybe using gcc flag -Wlogical-op might help find bugs like this in future. -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/1813460 Title: qemu/target/arm/translate-a64.c:2039: bad test ? Status in

[Qemu-devel] [Bug 1813460] [NEW] qemu/target/arm/translate-a64.c:2039: bad test ?

2019-01-27 Thread dcb
Public bug reported: qemu/target/arm/translate-a64.c:2039]: (warning) Logical disjunction always evaluates to true: op3 != 2 || op3 != 3. Source code is if (op3 != 2 || op3 != 3) { Maybe better code if (op3 != 2 && op3 != 3) { ** Affects: qemu Importance: Undecided

[Qemu-devel] [Bug 1811499] [NEW] qemu/net/colo-compare.c:288: possible pointless code duplication ?

2019-01-12 Thread dcb
Public bug reported: qemu/net/colo-compare.c:288] -> [qemu/net/colo-compare.c:296]: (style) The if condition is the same as the previous if condition Source code is if (ppkt->tcp_seq == spkt->tcp_seq && ppkt->seq_end == spkt->seq_end) { if (colo_compare_packet_payload(ppkt, spkt,

[Qemu-devel] [Bug 1798780] [NEW] hw/usb/dev-mtp.c:1616: bad test ?

2018-10-19 Thread dcb
Public bug reported: hw/usb/dev-mtp.c:1616:52: warning: logical ‘or’ of collectively exhaustive tests is always true [-Wlogical-op] Source code is if ((ret == -1) && (errno != EINTR || errno != EAGAIN || errno != EWOULDBLOCK)) { Maybe better c

[Qemu-devel] [Bug 1753437] [NEW] qemu/pc-bios/s390-ccw/libc.c:82: bad test ?

2018-03-05 Thread dcb
Public bug reported: qemu/pc-bios/s390-ccw/libc.c:82]: (style) Unsigned variable 'num_idx' can't be negative so it is unnecessary to test it. Source code is while (num_idx >= 0) { but size_t num_idx = 1; /* account for NUL */ So there is no escape from the while loop. ** Affects: qe

[Qemu-devel] [Bug 1720971] [NEW] qemu/hw/block/onenand.c:522: strange if statement ?

2017-10-03 Thread dcb
Public bug reported: [qemu/hw/block/onenand.c:523]: (warning) Opposite inner 'if' condition leads to a dead code block. Source code is for (b = 0; b < s->blocks; b ++) { if (b >= s->blocks) { s->status |= ONEN_ERR_CMD; break; } Inne

[Qemu-devel] [Bug 1720969] [NEW] qemu/memory.c:206: pointless copies of large structs ?

2017-10-03 Thread dcb
Public bug reported: [qemu/memory.c:206]: (performance) Function parameter 'a' should be passed by reference. [qemu/memory.c:207]: (performance) Function parameter 'b' should be passed by reference. Source code is static bool memory_region_ioeventfd_equal(MemoryRegionIoeventfd a,

[Qemu-devel] [Bug 1715007] [NEW] hw/block/onenand.c:520: dead code ?

2017-09-04 Thread dcb
Public bug reported: qemu/hw/block/onenand.c:520] -> [qemu/hw/block/onenand.c:521]: (warning) Opposite inner 'if' condition leads to a dead code block. Source code is for (b = 0; b < s->blocks; b ++) { if (b >= s->blocks) { s->status |= ONEN_ERR_CMD;

[Qemu-devel] [Bug 1660035] [NEW] hw/timer/altera_timer.c:207: bad size in memset ?

2017-01-28 Thread dcb
Public bug reported: hw/timer/altera_timer.c:207:5: warning: ‘memset’ used with length equal to number of elements without multiplication by element size [-Wmemset- elt-size] Source code is memset(t->regs, 0, ARRAY_SIZE(t->regs)); Maybe better code memset(t->regs, 0, R_MAX * sizeof(

[Qemu-devel] [Bug 1658506] [NEW] qemu/hw/intc/arm_gicv3_cpuif.c:2433: bad expression ?

2017-01-22 Thread dcb
Public bug reported: qemu/hw/intc/arm_gicv3_cpuif.c:2433]: (style) Expression '(X & 0x2000) == 0x1' is always false. Source code is ((lr & ICH_LR_EL2_HW) == 1 || (lr & ICH_LR_EL2_EOI) == 0)) { Maybe better code ((lr & ICH_LR_EL2_HW) != 0 || (lr & ICH_LR_EL2_EO

[Qemu-devel] [Bug 1655708] Re: target/ppc/int_helper.c:2806: strange expression ?

2017-01-11 Thread dcb
> so it is just as easy to write 'i ? ...' instead of the weirder > '(i * 2) ? ...'. I suspect it is just possible that the i * 2 expression is a typo for something else, perhaps i & 2 or i << 2 or i >> 2 or something else. I don't know the code so I am unable to offer better guidance. -- You r

[Qemu-devel] [Bug 1655708] [NEW] target/ppc/int_helper.c:2806: strange expression ?

2017-01-11 Thread dcb
Public bug reported: target/ppc/int_helper.c:2806:25: warning: ‘*’ in boolean context, suggest ‘&&’ instead [-Wint-in-bool-context] Source code is zone_digit = (i * 2) ? b->u8[BCD_DIG_BYTE(i * 2)] >> 4 : zone_lead; Which I read as zone_digit = (i * 2) ? (b->u8[BCD_DIG_BYTE(i * 2)

[Qemu-devel] [Bug 1655702] [NEW] qemu/hw/char/exynos4210_uart.c: possible pointless local variable ?

2017-01-11 Thread dcb
Public bug reported: $ fgrep frame_size qemu/hw/char/exynos4210_uart.c int speed, parity, data_bits, stop_bits, frame_size; frame_size = 1; /* start bit */ frame_size++; /* parity bit */ frame_size += data_bits + stop_bits; $ Suggest either use it or delete it. ** Affects: qe

[Qemu-devel] [Bug 1655700] [NEW] disas/libvixl/vixl/invalset.h: possible dodgy code in binary search ?

2017-01-11 Thread dcb
Public bug reported: [qemu/disas/libvixl/vixl/invalset.h:442]: (style) Array index 'low' is used before limits check. Source code is while (!IsValid(elements[low]) && (low < high)) ++low; Also: qemu/disas/libvixl/vixl/invalset.h:450]: (style) Array index 'middle' is used before limits ch

[Qemu-devel] [Bug 1651167] [NEW] hw/ipmi/isa_ipmi_bt.c:283: suspect use of macro ?

2016-12-19 Thread dcb
Public bug reported: I just had a go at compiling qemu trunk with llvm trunk. It said: hw/ipmi/isa_ipmi_bt.c:283:31: warning: logical not is only applied to the left hand side of this bitwise operator [-Wlogical-not-parentheses] Source code is IPMI_BT_SET_HBUSY(ib->control_reg,

[Qemu-devel] [Bug 1643537] [NEW] target-ppc/int_helper.c: 2 * bad array index

2016-11-21 Thread dcb
Public bug reported: 1. [qemu/target-ppc/int_helper.c:2575]: (error) Array 'reg.u16[8]' accessed at index 8, which is out of bounds. Source code is return reg->u16[8 - n]; and qemu/target-ppc/cpu.h:uint16_t u16[8]; but at least once, n is zero, for example line 2725 in the int_helper.

[Qemu-devel] [Bug 1631773] [NEW] hw/dma/pl080.c:354: possible typo ?

2016-10-09 Thread dcb
Public bug reported: hw/dma/pl080.c:354:1: warning: V578 An odd bitwise operation detected: s->conf & (0x2 | 0x2). Consider verifying it. Source code is if (s->conf & (PL080_CONF_M1 | PL080_CONF_M1)) { Maybe better code if (s->conf & (PL080_CONF_M1 | PL080_CONF_M2)) { ** Affects

[Qemu-devel] [Bug 1631625] [NEW] target-mips/dsp_helper.c: two possible bad shifts

2016-10-08 Thread dcb
Public bug reported: target-mips/dsp_helper.c:3480:1: error: V629 Consider inspecting the '0x01 << (size + 1)' expression. Bit shifting of the 32-bit value with a subsequent expansion to the 64-bit type. Source code is temp = temp & ((0x01 << (size + 1)) - 1); If size >= 32, then better

[Qemu-devel] [Bug 1630527] [NEW] qemu/hw/i386/amd_iommu.c:188: possible bad shift ?

2016-10-05 Thread dcb
Public bug reported: qemu/hw/i386/amd_iommu.c:188]: (error) Shifting 32-bit value by 64 bits is undefined behaviour Source code is uint64_t mask = ((1 << length) - 1) << bitpos; Maybe better code uint64_t mask = ((1ULL << length) - 1) << bitpos; ** Affects: qemu Importance: Undec

[Qemu-devel] [Bug 1625987] [NEW] target-arm/translate-a64.c:2028: possible coding error ?

2016-09-21 Thread dcb
Public bug reported: target-arm/translate-a64.c:2028:37: warning: ?: using integer constants in boolean context [-Wint-in-bool-context] Source code is bool iss_sf = opc == 0 ? 32 : 64; Maybe better code bool iss_sf = (opc == 0) ? 32 : 64; ** Affects: qemu Importance: Unde

[Qemu-devel] [Bug 1589564] Re: qemu/hw/scsi/scsi-disk.c:2741: possible missing break ?

2016-06-11 Thread dcb
>I am currently not able to reproduce the problem with the format strings ... >how did you get them? Which compiler (and version) did you use? I used a static analyser for C & C++ called cppcheck. It is available from sourceforge. I find it very useful. I think gcc might be able to reproduce the

[Qemu-devel] [Bug 1589564] [NEW] qemu/hw/scsi/scsi-disk.c:2741: possible missing break ?

2016-06-06 Thread dcb
Public bug reported: qemu/hw/scsi/scsi-disk.c:2741] -> [qemu/hw/scsi/scsi-disk.c:2745]: (warning) Variable 'cdb1' is reassigned a value before the old one has been used. 'break;' missing? qemu/hw/scsi/scsi-disk.c:2742] -> [qemu/hw/scsi/scsi-disk.c:2746]: (warning) Variable 'group_number' is rea

[Qemu-devel] [Bug 1577841] [NEW] target-mips/helper.c:542: bad sizeof ?

2016-05-03 Thread dcb
Public bug reported: Recent versions of gcc say this: qemu/target-mips/helper.c:542:9: warning: ‘memset’ used with length equal to number of elements without multiplication by element size [-Wmemset-elt-size] Source code is memset(env->CP0_WatchLo, 0, sizeof(*env->CP0_WatchLo)); Maybe bette

[Qemu-devel] [Bug 1550503] [NEW] target-arm/helper.c:5493: bad test ?

2016-02-26 Thread dcb
Public bug reported: [qemu/target-arm/helper.c:5493]: (style) Expression '(X & 0x1f) != 0xf80f' is always true. Source code is (env->uncached_cpsr & CPSR_M) != CPSR_USER && but ./qemu/target-arm/cpu.h:#define CPSR_M (0x1fU) ./qemu/target-arm/cpu.h:#define CPSR_USER (CPSR_NZCV | CP

[Qemu-devel] [Bug 1533141] Re: qemu/disas/libvixl/vixl/invalset.h: 2 * sanity check after use ?

2016-01-12 Thread dcb
>If you want to suggest coding style changes to it I would recommend reporting >them to the upstream project: Thanks. Done here: https://github.com/armvixl/vixl/issues -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.l

[Qemu-devel] [Bug 1533141] [NEW] qemu/disas/libvixl/vixl/invalset.h: 2 * sanity check after use ?

2016-01-12 Thread dcb
Public bug reported: 1. [qemu/disas/libvixl/vixl/invalset.h:442]: (style) Array index 'low' is used before limits check. while (!IsValid(elements[low]) && (low < high)) ++low; 2. [qemu/disas/libvixl/vixl/invalset.h:450]: (style) Array index 'middle' is used before limits check. while (!IsV

[Qemu-devel] [Bug 1497711] [NEW] tests/libqos/ahci.c:745: redundant condition ?

2015-09-20 Thread dcb
Public bug reported: [qemu/tests/libqos/ahci.c:745]: (style) Redundant condition: props.ncq. '!props.ncq || (props.ncq && props.lba48)' is equivalent to '!props.ncq || props.lba48' g_assert(!props->ncq || (props->ncq && props->lba48)); ** Affects: qemu Importance: Undecided Sta

[Qemu-devel] [Bug 1464611] Re: 4 * redundant conditions

2015-06-12 Thread dcb
>These three are all straightforward and would look simpler >in their simplified versions... Agreed. The first 3 look valid candidates for simplification. > 4. > > [qemu/target-arm/translate-a64.c:5729]: (style) Redundant condition: > size<3. 'A && (!A || B)' is equivalent to 'A || B' > > i

[Qemu-devel] [Bug 1464611] [NEW] 4 * redundant conditions

2015-06-12 Thread dcb
Public bug reported: 1. [qemu/hw/block/nvme.c:355]: (style) Redundant condition: sqid. 'A && (!A || B)' is equivalent to 'A || B' if (!sqid || (sqid && !nvme_check_sqid(n, sqid))) { 2. [qemu/hw/block/nvme.c:429]: (style) Redundant condition: cqid. 'A && (!A || B)' is equivalent to 'A || B'

[Qemu-devel] [Bug 1460523] [NEW] target-arm/op_helper.c:424: bad assert

2015-05-31 Thread dcb
Public bug reported: /home/dcb/qemu/trunk/qemu/target-arm/op_helper.c: In function ‘helper_access_check_cp_reg’: /home/dcb/qemu/trunk/qemu/target-arm/op_helper.c:424:52: error: comparison of constant ‘3’ with boolean expression is always false [-Werror=bool-compare] assert

[Qemu-devel] [Bug 1437811] [NEW] target-tricore/op_helper.c:2576: bad if statement

2015-03-29 Thread dcb
Public bug reported: [qemu/target-tricore/op_helper.c:2576]: (style) Expression '(X & 0x40) == 0x1' is always false. if ((env->PCXI & MASK_PCXI_UL) == 1) { /* CTYP trap */ } ** Affects: qemu Importance: Undecided Status: New -- You received this bug notificati

[Qemu-devel] [Bug 1414293] [NEW] target-lm32/translate.c:336: bad ? : operator

2015-01-24 Thread dcb
Public bug reported: [qemu/target-lm32/translate.c:336]: (style) Same expression in both branches of ternary operator. int rY = (dc->format == OP_FMT_RR) ? dc->r0 : dc->r0; ** Affects: qemu Importance: Undecided Status: New -- You received this bug notification because you are

[Qemu-devel] [Bug 1402802] [NEW] target-tricore/translate.c:3812: possible bad expression ?

2014-12-15 Thread dcb
Public bug reported: >From a run of cppcheck, a static analysis checker, over the source code of qemu trunk, dated 20141215, is the new error: [qemu/target-tricore/translate.c:3812]: (style) Expression '(X & 0x3f) == 0x6f' is always false. Source code is if (unlikely((op1 & 0x3f) == OPCM_3

[Qemu-devel] [Bug 1393486] [NEW] hw/virtio/virtio-rng.c:150: bad test ?

2014-11-17 Thread dcb
Public bug reported: hw/virtio/virtio-rng.c:150:31: warning: logical not is only applied to the left hand side of comparison [-Wlogical-not-parentheses] if (!vrng->conf.period_ms > 0) { error_setg(errp, "'period' parameter expects a positive integer"); return; } Maybe bet

[Qemu-devel] [Bug 1393440] [NEW] pcie.c:148: possible error in OR expression ?

2014-11-17 Thread dcb
Public bug reported: [qemu/hw/pci/pcie.c:148] -> [qemu/hw/pci/pcie.c:148]: (style) Same expression on both sides of '|'. pci_long_test_and_set_mask(dev->w1cmask + pos + PCI_EXP_DEVSTA, PCI_EXP_DEVSTA_CED | PCI_EXP_DEVSTA_NFED | PCI

[Qemu-devel] [Bug 1382477] [NEW] hw/i386/intel_iommu.c:902: wrong logical operator ?

2014-10-17 Thread dcb
Public bug reported: /home/dcb/qemu/trunk/qemu/hw/i386/intel_iommu.c:902:5: error: logical ‘and’ applied to non-boolean constant [-Werror=logical-op] pvtd_as = s->address_spaces[VTD_SID_TO_BUS(source_id)]; ^ $ fgrep VTD_SID_TO_BUS `find . -name \*.h -print` ./include/hw/i

[Qemu-devel] [Bug 1381639] [NEW] sys_eeprom.c:353: buffer too small

2014-10-15 Thread dcb
Public bug reported: [qemu-2.1.2/roms/u-boot/board/matrix_vision/mvblx/sys_eeprom.c:353]: (error) Buffer is accessed out of bounds. char ethaddr[9]; sprintf(ethaddr, "%02X:%02X:%02X:%02X:%02X:%02X", e.mac[0], e.mac[1], e.mac[2], e.m

[Qemu-devel] [Bug 1381642] [NEW] ecovec.c:66: buffer too small by one.

2014-10-15 Thread dcb
Public bug reported: [qemu-2.1.2/roms/u-boot/board/renesas/ecovec/ecovec.c:66]: (error) Buffer is accessed out of bounds. sprintf(env_mac, "%02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); but char env_mac[17]; and 18 into 17 won't go. Suggest in

[Qemu-devel] [Bug 1321464] [NEW] qemu/block/qcow2.c:1942: possible performance problem ?

2014-05-20 Thread dcb
Public bug reported: I just ran static analyser cppcheck over today (20140520) qemu source code. It said many things, including [qemu/block/qcow2.c:1942] -> [qemu/block/qcow2.c:1943]: (performance) Buffer 'pad_buf' is being writ ten before its old content has been used. Source code is

[Qemu-devel] [Bug 1279257] [NEW] [hw/scsi/scsi-bus.c:910]: (style) Expression '(X & 0x4) == 0x1' is always false.

2014-02-12 Thread dcb
Public bug reported: Source code is } else if ((buf[1] & 4) == 1) { Suggest code rework. I found this bug by running static analyser cppcheck over the source code. I also checked the latest code on the web and the bug exists there also. ** Affects: qemu Importance: Undecided