[haiku-development] Re: batch of small patches

  • From: viktor muntzing <viktor.muntzing@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Thu, 14 Jan 2016 20:28:26 +0100

2016-01-11 21:33 GMT+01:00 viktor muntzing <viktor.muntzing@xxxxxxxxx>:

oops, sorry.

I'm checking with cppcheck. Will provide a new patch

2016-01-11 21:18 GMT+01:00 Adrien Destugues <pulkomandy@xxxxxxxxx>:

On Mon, Jan 11, 2016 at 08:34:27PM +0100, viktor muntzing wrote:
Picking some low hanging fruits from static analysis :)

Did you use the existing coverity or PVS scans? If so, it would help if
you could mention the issue numbers.

Subject: [PATCH 2/4] acpi - NamespaceDump - Removed compare to less
than 0 and
better check of byte length


- if (toWrite <= 0)
+ if (toWrite = 0)
break;

Please review your patches before submitting.

--
Adrien.


Attaching new set of patches
From 10bdfc8309237dc529b37fd1a3be61d89cfae164 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Viktor=20M=C3=BCntzing?= <viktor.muntzing@xxxxxxxxx>
Date: Mon, 11 Jan 2016 20:02:15 +0100
Subject: [PATCH 1/4] Fix incorrect paranthesis in intel_extreme - overlay

---
src/add-ons/accelerants/intel_extreme/overlay.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/add-ons/accelerants/intel_extreme/overlay.cpp
b/src/add-ons/accelerants/intel_extreme/overlay.cpp
index 2d4f41e..5b6d151 100644
--- a/src/add-ons/accelerants/intel_extreme/overlay.cpp
+++ b/src/add-ons/accelerants/intel_extreme/overlay.cpp
@@ -573,7 +573,7 @@ intel_configure_overlay(overlay_token overlayToken,
}

if (!gInfo->shared_info->overlay_active
- || memcmp(&gInfo->last_overlay_view, view, sizeof(overlay_view)
!= 0)
+ || memcmp(&gInfo->last_overlay_view, view,
sizeof(overlay_view)) != 0
|| memcmp(&gInfo->last_overlay_frame, window,
sizeof(overlay_frame)) != 0) {
// scaling has changed, program window and scaling factor

--
2.5.0

From 327685c9abe06dee5d817aaf702df564b3d5ae18 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Viktor=20M=C3=BCntzing?= <viktor.muntzing@xxxxxxxxx>
Date: Mon, 11 Jan 2016 20:16:29 +0100
Subject: [PATCH 2/4] acpi - NamespaceDump - Removed compare to less than 0 and
better check of byte length

---
src/add-ons/kernel/bus_managers/acpi/NamespaceDump.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/add-ons/kernel/bus_managers/acpi/NamespaceDump.cpp
b/src/add-ons/kernel/bus_managers/acpi/NamespaceDump.cpp
index b71ce48..f2fb5a1 100644
--- a/src/add-ons/kernel/bus_managers/acpi/NamespaceDump.cpp
+++ b/src/add-ons/kernel/bus_managers/acpi/NamespaceDump.cpp
@@ -149,11 +149,11 @@ dump_acpi_namespace(acpi_ns_device_info *device, char
*root, int indenting)
RingBuffer &ringBuffer = *device->buffer;
size_t toWrite = strlen(output);

- if (toWrite <= 0)
+ if (toWrite == 0)
break;

- strlcat(output, "\n", sizeof(output));
- toWrite++;
+ toWrite = strlcat(output, "\n", sizeof(output));
+
if (!ringBuffer.Lock())
break;

--
2.5.0

From 38cdec642e0c47a07ec3a025cb9cdbce9a27a45f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Viktor=20M=C3=BCntzing?= <viktor.muntzing@xxxxxxxxx>
Date: Mon, 11 Jan 2016 20:19:10 +0100
Subject: [PATCH 3/4] radeon - CP_setup - Fixed a probably copy/paste misstake
- No hardware so can't verify myself.

---
src/add-ons/kernel/drivers/graphics/radeon/CP_setup.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/add-ons/kernel/drivers/graphics/radeon/CP_setup.c
b/src/add-ons/kernel/drivers/graphics/radeon/CP_setup.c
index b36d5e7..0143610 100644
--- a/src/add-ons/kernel/drivers/graphics/radeon/CP_setup.c
+++ b/src/add-ons/kernel/drivers/graphics/radeon/CP_setup.c
@@ -700,7 +700,7 @@ void Radeon_SetDynamicClock( device_info *di, int mode)
R300_PIXCLK_TRANS_ALWAYS_ONb |
R300_PIXCLK_TVO_ALWAYS_ONb |
R300_P2G2CLK_ALWAYS_ONb |
- R300_P2G2CLK_ALWAYS_ONb |
+ R300_P2G2CLK_DAC_ALWAYS_ONb |
R300_DISP_DAC_PIXCLK_DAC2_BLANK_OFF);
Radeon_OUTPLL(regs, asic, RADEON_PIXCLKS_CNTL, tmp);
} else {
@@ -826,7 +826,7 @@ void Radeon_SetDynamicClock( device_info *di, int mode)

tmp = Radeon_INPLL(regs, asic,
RADEON_PIXCLKS_CNTL);
tmp |= (RADEON_PIX2CLK_ALWAYS_ONb |
- RADEON_PIX2CLK_DAC_ALWAYS_ONb |
+ RADEON_PIX2CLK_DAC_ALWAYS_ONb |
RADEON_DISP_TVOUT_PIXCLK_TV_ALWAYS_ONb |
R300_DVOCLK_ALWAYS_ONb |
RADEON_PIXCLK_BLEND_ALWAYS_ONb |
@@ -837,7 +837,7 @@ void Radeon_SetDynamicClock( device_info *di, int mode)
R300_PIXCLK_TRANS_ALWAYS_ONb |
R300_PIXCLK_TVO_ALWAYS_ONb |
R300_P2G2CLK_ALWAYS_ONb |
- R300_P2G2CLK_ALWAYS_ONb);
+ R300_P2G2CLK_DAC_ALWAYS_ONb);
Radeon_OUTPLL(regs, asic, RADEON_PIXCLKS_CNTL,
tmp);

tmp = Radeon_INPLL(regs, asic,
RADEON_MCLK_MISC);
--
2.5.0

From f96e2078d4713ec0239382e353507b17faa31f18 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Viktor=20M=C3=BCntzing?= <viktor.muntzing@xxxxxxxxx>
Date: Mon, 11 Jan 2016 20:26:12 +0100
Subject: [PATCH 4/4] virtio_net driver - Obvious misstake in comparision for
NULL

---
src/add-ons/kernel/drivers/network/virtio/virtio_net.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/add-ons/kernel/drivers/network/virtio/virtio_net.cpp
b/src/add-ons/kernel/drivers/network/virtio/virtio_net.cpp
index 4a6a66e..0f8c4cc 100644
--- a/src/add-ons/kernel/drivers/network/virtio/virtio_net.cpp
+++ b/src/add-ons/kernel/drivers/network/virtio/virtio_net.cpp
@@ -160,7 +160,7 @@ virtio_net_init_device(void* _info, void** _cookie)

info->receive_queues = new(std::nothrow)
virtio_queue[info->pairs_count];
info->send_queues = new(std::nothrow) virtio_queue[info->pairs_count];
- if (info->receive_queues == NULL || info->receive_queues == NULL)
+ if (info->receive_queues == NULL || info->send_queues == NULL)
return B_NO_MEMORY;
for (uint32 i = 0; i < info->pairs_count; i++) {
info->receive_queues[i] = virtioQueues[i * 2];
--
2.5.0

Other related posts: