From ff38df48cfb21b95fb2dce0443762e0e470db57c Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Tue, 16 Jul 2019 20:45:26 +0200 Subject: [PATCH] PVS V568: strange uses of sizeof MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I4c4e0395f579cf3b5ec4db2c30bbe2dc2d866de7 Reviewed-on: https://review.haiku-os.org/c/1608 Reviewed-by: Stephan Aßmus --- src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.cpp | 2 +- src/add-ons/kernel/drivers/disk/scsi/scsi_disk/scsi_disk.cpp | 2 +- src/add-ons/kernel/file_systems/ext2/ext2.h | 2 +- src/add-ons/kernel/file_systems/nfs4/RequestBuilder.cpp | 4 ++-- src/preferences/appearance/ColorPreview.cpp | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.cpp b/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.cpp index 36270b8422..6ba45d247b 100644 --- a/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.cpp +++ b/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.cpp @@ -1101,7 +1101,7 @@ cd_register_device(device_node* node) // get inquiry data if (sDeviceManager->get_attr_raw(node, SCSI_DEVICE_INQUIRY_ITEM, (const void**)&deviceInquiry, &inquiryLength, true) != B_OK - || inquiryLength < sizeof(deviceInquiry)) + || inquiryLength < sizeof(scsi_res_inquiry)) return B_ERROR; // get block limit of underlying hardware to lower it (if necessary) diff --git a/src/add-ons/kernel/drivers/disk/scsi/scsi_disk/scsi_disk.cpp b/src/add-ons/kernel/drivers/disk/scsi/scsi_disk/scsi_disk.cpp index 6dbc3c0403..5d6e0619ad 100644 --- a/src/add-ons/kernel/drivers/disk/scsi/scsi_disk/scsi_disk.cpp +++ b/src/add-ons/kernel/drivers/disk/scsi/scsi_disk/scsi_disk.cpp @@ -541,7 +541,7 @@ das_register_device(device_node *node) // get inquiry data if (sDeviceManager->get_attr_raw(node, SCSI_DEVICE_INQUIRY_ITEM, (const void **)&deviceInquiry, &inquiryLength, true) != B_OK - || inquiryLength < sizeof(deviceInquiry)) + || inquiryLength < sizeof(scsi_res_inquiry)) return B_ERROR; // get block limit of underlying hardware to lower it (if necessary) diff --git a/src/add-ons/kernel/file_systems/ext2/ext2.h b/src/add-ons/kernel/file_systems/ext2/ext2.h index 5ba37af23e..8b4da0c5c2 100644 --- a/src/add-ons/kernel/file_systems/ext2/ext2.h +++ b/src/add-ons/kernel/file_systems/ext2/ext2.h @@ -779,7 +779,7 @@ struct ext2_xattr_entry { } void Dump(bool full=false) const { - for (unsigned int i = 0; i < (full ? sizeof(this) : MinimumSize()); i++) + for (unsigned int i = 0; i < (full ? sizeof(*this) : MinimumSize()); i++) dprintf("%02x ", ((uint8 *)this)[i]); dprintf("\n"); } diff --git a/src/add-ons/kernel/file_systems/nfs4/RequestBuilder.cpp b/src/add-ons/kernel/file_systems/nfs4/RequestBuilder.cpp index e518f86681..3ee50fe18d 100644 --- a/src/add-ons/kernel/file_systems/nfs4/RequestBuilder.cpp +++ b/src/add-ons/kernel/file_systems/nfs4/RequestBuilder.cpp @@ -710,10 +710,10 @@ RequestBuilder::_GenerateClientId(XDR::WriteStream& stream, PeerAddress local = server->LocalID(); memcpy(id + pos, server->ID().InAddr(), server->ID().InAddrSize()); - pos += sizeof(server->ID().InAddrSize()); + pos += server->ID().InAddrSize(); memcpy(id + pos, local.InAddr(), local.InAddrSize()); - pos += sizeof(local.InAddrSize()); + pos += local.InAddrSize(); *(uint16*)(id + pos) = server->ID().Port(); pos += sizeof(uint16); diff --git a/src/preferences/appearance/ColorPreview.cpp b/src/preferences/appearance/ColorPreview.cpp index df82cd585d..54ea2e5a01 100644 --- a/src/preferences/appearance/ColorPreview.cpp +++ b/src/preferences/appearance/ColorPreview.cpp @@ -124,7 +124,7 @@ ColorPreview::MessageReceived(BMessage* message) (const void**)&color, &size) == B_OK) { BMessage setColorMessage(SET_CURRENT_COLOR); setColorMessage.AddData(kRGBColor, B_RGB_COLOR_TYPE, color, - sizeof(color)); + sizeof(rgb_color)); Invoke(&setColorMessage); } } else if ((int32)message->what == kMsgMessageRunner) {