[haiku-commits] haiku: hrev45558 - in src: add-ons/kernel/bus_managers/pci system/kernel/vm system/boot/platform/bios_ia32 apps/icon-o-matic/generic/gui/panel/color_picker .

  • From: korli@xxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 26 Apr 2013 21:20:20 +0200 (CEST)

hrev45558 adds 9 changesets to branch 'master'
old head: 3e9e1e11b293cd0047104600ec1d82acbe323967
new head: f7176b0ee50d5367762d904a943a693b0a8e3e2f
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=f7176b0+%5E3e9e1e1

----------------------------------------------------------------------------

40cf1c0: net_server: 0xff is out of the bound of char, use uint8 instead
  
  * found by GCC 4.7.3

d762df1: GCC 4.7.x doesn't allow setting a field in a referenced packed struct.
  
  * error message: error: cannot bind packed field
  'args->kernel_args::platform_args.platform_kernel_args::apm' to 'apm_info&'
  * the reason would be that the reference doesn't have alignment information 
anymore.
  * changed the reference to const for read access, and use the long form for 
setting a field.

f92b1f2: GCC 4.7.x finds that 1 << 31 is a signed integer, use the unsigned 
notation
  
  * error: narrowing conversion of '-2147483618' from 'int' to 'uint32 {aka 
long unsigned int}'
   inside { } is ill-formed in C++11

8b9c071: PCI bus manager: changed the type of domain from int to uint8.
  
  * fixed narrowing conversion problem found by GCC 4.7.

848acd6: devfs: casts as size_t before comparing.
  
  * error: comparison between signed and unsigned integer expressions.

44d2f5f: scsi bus manager: casts path_id to uint8.
  
  * added a TODO about create_id() generating int32 ids when we need uint8.
  * GCC 4.7 warning fixed: narrowing conversion.

5f08555: GCC 4.7.x doesn't allow writes in a referenced packed struct.
  
  * error: cannot bind packed field 'image->preloaded_elf64_image::elf_header'
      to 'ELFLoader<ELF64Class>::EhdrType& {aka Elf64_Ehdr&}'

cc3fb1f: icon-o-matic: converts the result of round() to uint8 to fit in struct 
rgb_color.
  
  * GCC 4.7 warning: narrowing conversion of 
'(int)(((ColorPickerView*)this)->ColorPickerView::r * 2.55e+2f)'
  from 'int' to 'uint8 {aka unsigned char}' inside { } is ill-formed in C++11 
[-Werror=narrowing]

f7176b0: VMAnonymousCache.cpp: changed page_index type to page_num_t
  
  * consistently use page_num_t for page numbers and off_t for offsets and 
sizes.

                                   [ Jérôme Duval <jerome.duval@xxxxxxxxx> ]

----------------------------------------------------------------------------

19 files changed, 152 insertions(+), 133 deletions(-)
headers/private/graphics/video_overlay.h         |  2 +-
.../kernel/bus_managers/pci/arch/x86/pci_msi.cpp | 10 +--
src/add-ons/kernel/bus_managers/pci/pci.cpp      | 78 ++++++++++----------
src/add-ons/kernel/bus_managers/pci/pci.h        | 43 ++++++-----
.../kernel/bus_managers/pci/pci_device.cpp       |  4 +-
.../kernel/bus_managers/pci/pci_fixup.cpp        | 12 +--
src/add-ons/kernel/bus_managers/pci/pci_fixup.h  |  5 +-
src/add-ons/kernel/bus_managers/pci/pci_info.cpp |  2 +-
src/add-ons/kernel/bus_managers/pci/pci_root.cpp |  4 +-
.../kernel/bus_managers/scsi/sim_interface.cpp   |  5 +-
.../gui/panel/color_picker/ColorField.cpp        |  3 +-
.../gui/panel/color_picker/ColorPickerView.cpp   | 12 ++-
src/servers/net/NetServer.cpp                    |  4 +-
src/system/boot/loader/elf.cpp                   | 12 +--
src/system/boot/platform/bios_ia32/apm.cpp       | 22 +++---
src/system/kernel/arch/x86/32/apm.cpp            | 11 ++-
src/system/kernel/device_manager/devfs.cpp       |  2 +-
src/system/kernel/vm/VMAnonymousCache.cpp        | 44 +++++------
src/system/kernel/vm/VMAnonymousCache.h          | 10 +--

############################################################################

Commit:      40cf1c0518157303a9bb6a64588e5ed7c81bb28a
URL:         http://cgit.haiku-os.org/haiku/commit/?id=40cf1c0
Author:      Jérôme Duval <jerome.duval@xxxxxxxxx>
Date:        Thu Apr 25 15:41:23 2013 UTC

net_server: 0xff is out of the bound of char, use uint8 instead

* found by GCC 4.7.3

----------------------------------------------------------------------------

diff --git a/src/servers/net/NetServer.cpp b/src/servers/net/NetServer.cpp
index da8472c..4935e2c 100644
--- a/src/servers/net/NetServer.cpp
+++ b/src/servers/net/NetServer.cpp
@@ -895,8 +895,8 @@ NetServer::_ConfigureIPv6LinkLocal(const char* name)
        const uint8* mac = link.LinkLevelAddress();
 
        // Check for a few failure situations
-       static const char zeroMac[6] = {0, 0, 0, 0, 0, 0};
-       static const char fullMac[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
+       static const uint8 zeroMac[6] = {0, 0, 0, 0, 0, 0};
+       static const uint8 fullMac[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
        if (memcmp(mac, zeroMac, 6) == 0
                || memcmp(mac, fullMac, 6) == 0) {
                // Mac address is all 0 or all FF's

############################################################################

Commit:      d762df1df1e33784875302c754e2ed77415b3ee7
URL:         http://cgit.haiku-os.org/haiku/commit/?id=d762df1
Author:      Jérôme Duval <jerome.duval@xxxxxxxxx>
Date:        Thu Apr 25 16:08:05 2013 UTC

GCC 4.7.x doesn't allow setting a field in a referenced packed struct.

* error message: error: cannot bind packed field
'args->kernel_args::platform_args.platform_kernel_args::apm' to 'apm_info&'
* the reason would be that the reference doesn't have alignment information 
anymore.
* changed the reference to const for read access, and use the long form for 
setting a field.

----------------------------------------------------------------------------

diff --git a/src/system/boot/platform/bios_ia32/apm.cpp 
b/src/system/boot/platform/bios_ia32/apm.cpp
index 3e4aec1..9e71b08 100644
--- a/src/system/boot/platform/bios_ia32/apm.cpp
+++ b/src/system/boot/platform/bios_ia32/apm.cpp
@@ -36,9 +36,9 @@ apm_init(void)
                return B_ERROR;
        }
 
-       apm_info &info = gKernelArgs.platform_args.apm;
-       info.version = regs.eax & 0xffff;
-       info.flags = regs.ecx & 0xffff;
+       const apm_info &info = gKernelArgs.platform_args.apm;
+       gKernelArgs.platform_args.apm.version = regs.eax & 0xffff;
+       gKernelArgs.platform_args.apm.flags = regs.ecx & 0xffff;
 
        dprintf("APM version %d.%d available, flags %x.\n",
                (info.version >> 8) & 0xf, info.version & 0xf, info.flags);
@@ -64,19 +64,19 @@ apm_init(void)
        call_bios(0x15, &regs);
        if ((regs.flags & CARRY_FLAG) != 0) {
                // reset the version, so that the kernel won't try to use APM
-               info.version = 0;
+               gKernelArgs.platform_args.apm.version = 0;
                return B_ERROR;
        }
 
-       info.code32_segment_base = regs.eax & 0xffff;
-       info.code32_segment_offset = regs.ebx;
-       info.code32_segment_length = regs.esi & 0xffff;
+       gKernelArgs.platform_args.apm.code32_segment_base = regs.eax & 0xffff;
+       gKernelArgs.platform_args.apm.code32_segment_offset = regs.ebx;
+       gKernelArgs.platform_args.apm.code32_segment_length = regs.esi & 0xffff;
 
-       info.code16_segment_base = regs.ecx & 0xffff;
-       info.code16_segment_length = regs.esi >> 16;
+       gKernelArgs.platform_args.apm.code16_segment_base = regs.ecx & 0xffff;
+       gKernelArgs.platform_args.apm.code16_segment_length = regs.esi >> 16;
 
-       info.data_segment_base = regs.edx & 0xffff;
-       info.data_segment_length = regs.edi & 0xffff;
+       gKernelArgs.platform_args.apm.data_segment_base = regs.edx & 0xffff;
+       gKernelArgs.platform_args.apm.data_segment_length = regs.edi & 0xffff;
 
        TRACE(("  code32: 0x%x, 0x%lx, length 0x%x\n",
                info.code32_segment_base, info.code32_segment_offset, 
info.code32_segment_length));
diff --git a/src/system/kernel/arch/x86/32/apm.cpp 
b/src/system/kernel/arch/x86/32/apm.cpp
index f34b0b1..1c6b72b 100644
--- a/src/system/kernel/arch/x86/32/apm.cpp
+++ b/src/system/kernel/arch/x86/32/apm.cpp
@@ -274,7 +274,7 @@ apm_shutdown(void)
 status_t
 apm_init(kernel_args *args)
 {
-       apm_info &info = args->platform_args.apm;
+       const apm_info &info = args->platform_args.apm;
 
        TRACE(("apm_init()\n"));
 
@@ -338,11 +338,14 @@ apm_init(kernel_args *args)
        if ((info.data_segment_base << 4) < 0xe0000) {
                // use the BIOS data segment as data segment for APM
 
-               if (info.data_segment_length == 0)
-                       info.data_segment_length = B_PAGE_SIZE - 
info.data_segment_base;
+               if (info.data_segment_length == 0) {
+                       args->platform_args.apm.data_segment_length = 
B_PAGE_SIZE 
+                               - info.data_segment_base;
+               }
 
                set_segment_descriptor(&gGDT[APM_DATA_SEGMENT >> 3],
-                       (addr_t)gDmaAddress + (info.data_segment_base << 4), 
info.data_segment_length,
+                       (addr_t)gDmaAddress + (info.data_segment_base << 4),
+                       info.data_segment_length,
                        DT_DATA_WRITEABLE, DPL_KERNEL);
        } else {
                // use the BIOS area as data segment

############################################################################

Commit:      f92b1f2eaf0e152e04987be2930484fedf87146d
URL:         http://cgit.haiku-os.org/haiku/commit/?id=f92b1f2
Author:      Jérôme Duval <jerome.duval@xxxxxxxxx>
Date:        Thu Apr 25 16:22:53 2013 UTC

GCC 4.7.x finds that 1 << 31 is a signed integer, use the unsigned notation

* error: narrowing conversion of '-2147483618' from 'int' to 'uint32 {aka long 
unsigned int}'
 inside { } is ill-formed in C++11

----------------------------------------------------------------------------

diff --git a/headers/private/graphics/video_overlay.h 
b/headers/private/graphics/video_overlay.h
index ff7669d..556b363 100644
--- a/headers/private/graphics/video_overlay.h
+++ b/headers/private/graphics/video_overlay.h
@@ -14,7 +14,7 @@ extern "C" {
 #endif
 
 enum {
-       B_SUPPORTS_OVERLAYS = 1 << 31   // part of display_mode.flags
+       B_SUPPORTS_OVERLAYS = 1U << 31  // part of display_mode.flags
 };
 
 enum {

############################################################################

Commit:      8b9c0710cd302a4fe5a4920792fbc5659fe85b6c
URL:         http://cgit.haiku-os.org/haiku/commit/?id=8b9c071
Author:      Jérôme Duval <jerome.duval@xxxxxxxxx>
Date:        Fri Apr 26 16:17:51 2013 UTC

PCI bus manager: changed the type of domain from int to uint8.

* fixed narrowing conversion problem found by GCC 4.7.

----------------------------------------------------------------------------

diff --git a/src/add-ons/kernel/bus_managers/pci/arch/x86/pci_msi.cpp 
b/src/add-ons/kernel/bus_managers/pci/arch/x86/pci_msi.cpp
index 719c490..cbfe5ef 100644
--- a/src/add-ons/kernel/bus_managers/pci/arch/x86/pci_msi.cpp
+++ b/src/add-ons/kernel/bus_managers/pci/arch/x86/pci_msi.cpp
@@ -21,7 +21,7 @@ pci_get_msi_count(uint8 virtualBus, uint8 _device, uint8 
function)
                return 0;
 
        uint8 bus;
-       int domain;
+       uint8 domain;
        if (gPCI->ResolveVirtualBus(virtualBus, &domain, &bus) != B_OK)
                return 0;
 
@@ -48,7 +48,7 @@ pci_configure_msi(uint8 virtualBus, uint8 _device, uint8 
function,
                return B_BAD_VALUE;
 
        uint8 bus;
-       int domain;
+       uint8 domain;
        status_t result = gPCI->ResolveVirtualBus(virtualBus, &domain, &bus);
        if (result != B_OK)
                return result;
@@ -102,7 +102,7 @@ pci_unconfigure_msi(uint8 virtualBus, uint8 _device, uint8 
function)
                return B_UNSUPPORTED;
 
        uint8 bus;
-       int domain;
+       uint8 domain;
        status_t result = gPCI->ResolveVirtualBus(virtualBus, &domain, &bus);
        if (result != B_OK)
                return result;
@@ -138,7 +138,7 @@ pci_enable_msi(uint8 virtualBus, uint8 _device, uint8 
function)
                return B_UNSUPPORTED;
 
        uint8 bus;
-       int domain;
+       uint8 domain;
        status_t result = gPCI->ResolveVirtualBus(virtualBus, &domain, &bus);
        if (result != B_OK)
                return result;
@@ -176,7 +176,7 @@ pci_disable_msi(uint8 virtualBus, uint8 _device, uint8 
function)
                return B_UNSUPPORTED;
 
        uint8 bus;
-       int domain;
+       uint8 domain;
        status_t result = gPCI->ResolveVirtualBus(virtualBus, &domain, &bus);
        if (result != B_OK)
                return result;
diff --git a/src/add-ons/kernel/bus_managers/pci/pci.cpp 
b/src/add-ons/kernel/bus_managers/pci/pci.cpp
index 081b2fb..03658b0 100644
--- a/src/add-ons/kernel/bus_managers/pci/pci.cpp
+++ b/src/add-ons/kernel/bus_managers/pci/pci.cpp
@@ -47,7 +47,7 @@ pci_read_config(uint8 virtualBus, uint8 device, uint8 
function, uint8 offset,
        uint8 size)
 {
        uint8 bus;
-       int domain;
+       uint8 domain;
        uint32 value;
 
        if (gPCI->ResolveVirtualBus(virtualBus, &domain, &bus) != B_OK)
@@ -66,7 +66,7 @@ pci_write_config(uint8 virtualBus, uint8 device, uint8 
function, uint8 offset,
        uint8 size, uint32 value)
 {
        uint8 bus;
-       int domain;
+       uint8 domain;
        if (gPCI->ResolveVirtualBus(virtualBus, &domain, &bus) != B_OK)
                return;
 
@@ -79,7 +79,7 @@ pci_find_capability(uchar virtualBus, uchar device, uchar 
function,
        uchar capID, uchar *offset)
 {
        uint8 bus;
-       int domain;
+       uint8 domain;
        if (gPCI->ResolveVirtualBus(virtualBus, &domain, &bus) != B_OK)
                return B_ERROR;
 
@@ -93,7 +93,7 @@ pci_reserve_device(uchar virtualBus, uchar device, uchar 
function,
 {
        status_t status;
        uint8 bus;
-       int domain;
+       uint8 domain;
        TRACE(("pci_reserve_device(%d, %d, %d, %s)\n", virtualBus, device, 
function,
                driverName));
 
@@ -118,7 +118,7 @@ pci_reserve_device(uchar virtualBus, uchar device, uchar 
function,
                {B_DEVICE_BUS, B_STRING_TYPE, {string: "pci"}},
 
                // location on PCI bus
-               {B_PCI_DEVICE_DOMAIN, B_UINT32_TYPE, {ui32: domain}},
+               {B_PCI_DEVICE_DOMAIN, B_UINT8_TYPE, {ui8: domain}},
                {B_PCI_DEVICE_BUS, B_UINT8_TYPE, {ui8: bus}},
                {B_PCI_DEVICE_DEVICE, B_UINT8_TYPE, {ui8: device}},
                {B_PCI_DEVICE_FUNCTION, B_UINT8_TYPE, {ui8: function}},
@@ -191,7 +191,7 @@ pci_unreserve_device(uchar virtualBus, uchar device, uchar 
function,
 {
        status_t status;
        uint8 bus;
-       int domain;
+       uint8 domain;
        TRACE(("pci_unreserve_device(%d, %d, %d, %s)\n", virtualBus, device,
                function, driverName));
 
@@ -210,7 +210,7 @@ pci_unreserve_device(uchar virtualBus, uchar device, uchar 
function,
                {B_DEVICE_BUS, B_STRING_TYPE, {string: "pci"}},
 
                // location on PCI bus
-               {B_PCI_DEVICE_DOMAIN, B_UINT32_TYPE, {ui32: domain}},
+               {B_PCI_DEVICE_DOMAIN, B_UINT8_TYPE, {ui8: domain}},
                {B_PCI_DEVICE_BUS, B_UINT8_TYPE, {ui8: bus}},
                {B_PCI_DEVICE_DEVICE, B_UINT8_TYPE, {ui8: device}},
                {B_PCI_DEVICE_FUNCTION, B_UINT8_TYPE, {ui8: function}},
@@ -288,7 +288,7 @@ pci_update_interrupt_line(uchar virtualBus, uchar device, 
uchar function,
        uchar newInterruptLineValue)
 {
        uint8 bus;
-       int domain;
+       uint8 domain;
        if (gPCI->ResolveVirtualBus(virtualBus, &domain, &bus) != B_OK)
                return B_ERROR;
 
@@ -299,7 +299,7 @@ pci_update_interrupt_line(uchar virtualBus, uchar device, 
uchar function,
 
 // used by pci_info.cpp print_info_basic()
 void
-__pci_resolve_virtual_bus(uint8 virtualBus, int *domain, uint8 *bus)
+__pci_resolve_virtual_bus(uint8 virtualBus, uint8 *domain, uint8 *bus)
 {
        if (gPCI->ResolveVirtualBus(virtualBus, domain, bus) < B_OK)
                panic("ResolveVirtualBus failed");
@@ -532,7 +532,7 @@ void
 PCI::InitBus()
 {
        PCIBus **nextBus = &fRootBus;
-       for (int i = 0; i < fDomainCount; i++) {
+       for (uint8 i = 0; i < fDomainCount; i++) {
                PCIBus *bus = new PCIBus;
                bus->next = NULL;
                bus->parent = NULL;
@@ -544,13 +544,13 @@ PCI::InitBus()
        }
 
        if (fBusEnumeration) {
-               for (int i = 0; i < fDomainCount; i++) {
+               for (uint8 i = 0; i < fDomainCount; i++) {
                        _EnumerateBus(i, 0);
                }
        }
 
        if (1) {
-               for (int i = 0; i < fDomainCount; i++) {
+               for (uint8 i = 0; i < fDomainCount; i++) {
                        _FixupDevices(i, 0);
                }
        }
@@ -570,7 +570,7 @@ PCI::~PCI()
 
 
 status_t
-PCI::_CreateVirtualBus(int domain, uint8 bus, uint8 *virtualBus)
+PCI::_CreateVirtualBus(uint8 domain, uint8 bus, uint8 *virtualBus)
 {
 #if defined(__INTEL__) || defined(__x86_64__)
 
@@ -584,22 +584,23 @@ PCI::_CreateVirtualBus(int domain, uint8 bus, uint8 
*virtualBus)
 
        if (fNextVirtualBus > 0xff)
                panic("PCI::CreateVirtualBus: virtual bus number space 
exhausted");
-       if (unsigned(domain) > 0xff)
-               panic("PCI::CreateVirtualBus: domain %d too large", domain);
 
        uint16 value = domain << 8 | bus;
 
-       for (VirtualBusMap::Iterator it = fVirtualBusMap.Begin(); it != 
fVirtualBusMap.End(); ++it) {
+       for (VirtualBusMap::Iterator it = fVirtualBusMap.Begin();
+               it != fVirtualBusMap.End(); ++it) {
                if (it->Value() == value) {
                        *virtualBus = it->Key();
-                       FLOW("PCI::CreateVirtualBus: domain %d, bus %d already 
in map => virtualBus %d\n", domain, bus, *virtualBus);
+                       FLOW("PCI::CreateVirtualBus: domain %d, bus %d already 
in map => "
+                               "virtualBus %d\n", domain, bus, *virtualBus);
                        return B_OK;
                }
        }
 
        *virtualBus = fNextVirtualBus++;
 
-       FLOW("PCI::CreateVirtualBus: domain %d, bus %d => virtualBus %d\n", 
domain, bus, *virtualBus);
+       FLOW("PCI::CreateVirtualBus: domain %d, bus %d => virtualBus %d\n", 
domain,
+               bus, *virtualBus);
 
        return fVirtualBusMap.Insert(*virtualBus, value);
 
@@ -608,7 +609,7 @@ PCI::_CreateVirtualBus(int domain, uint8 bus, uint8 
*virtualBus)
 
 
 status_t
-PCI::ResolveVirtualBus(uint8 virtualBus, int *domain, uint8 *bus)
+PCI::ResolveVirtualBus(uint8 virtualBus, uint8 *domain, uint8 *bus)
 {
 #if defined(__INTEL__) || defined(__x86_64__)
 
@@ -650,20 +651,21 @@ PCI::AddController(pci_controller *controller, void 
*controller_cookie)
 void
 PCI::InitDomainData()
 {
-       for (int i = 0; i < fDomainCount; i++) {
+       for (uint8 i = 0; i < fDomainCount; i++) {
                int32 count;
                status_t status;
 
-               status = 
(*fDomainData[i].controller->get_max_bus_devices)(fDomainData[i].controller_cookie,
 &count);
+               status = (*fDomainData[i].controller->get_max_bus_devices)(
+                       fDomainData[i].controller_cookie, &count);
                fDomainData[i].max_bus_devices = (status == B_OK) ? count : 0;
        }
 }
 
 
 domain_data *
-PCI::_GetDomainData(int domain)
+PCI::_GetDomainData(uint8 domain)
 {
-       if (domain < 0 || domain >= fDomainCount)
+       if (domain >= fDomainCount)
                return NULL;
 
        return &fDomainData[domain];
@@ -671,7 +673,7 @@ PCI::_GetDomainData(int domain)
 
 
 inline int
-PCI::_NumFunctions(int domain, uint8 bus, uint8 device)
+PCI::_NumFunctions(uint8 domain, uint8 bus, uint8 device)
 {
        uint8 type = ReadConfig(domain, bus, device,
                0, PCI_header_type, 1);
@@ -716,7 +718,7 @@ PCI::_GetNthInfo(PCIBus *bus, long *currentIndex, long 
wantIndex,
 
 
 void
-PCI::_EnumerateBus(int domain, uint8 bus, uint8 *subordinateBus)
+PCI::_EnumerateBus(uint8 domain, uint8 bus, uint8 *subordinateBus)
 {
        TRACE(("PCI: EnumerateBus: domain %u, bus %u\n", domain, bus));
 
@@ -854,7 +856,7 @@ PCI::_EnumerateBus(int domain, uint8 bus, uint8 
*subordinateBus)
 
 
 void
-PCI::_FixupDevices(int domain, uint8 bus)
+PCI::_FixupDevices(uint8 domain, uint8 bus)
 {
        FLOW("PCI: FixupDevices domain %u, bus %u\n", domain, bus);
 
@@ -1100,7 +1102,7 @@ PCI::_DiscoverDevice(PCIBus *bus, uint8 dev, uint8 
function)
 
 
 PCIBus *
-PCI::_CreateBus(PCIDev *parent, int domain, uint8 bus)
+PCI::_CreateBus(PCIDev *parent, uint8 domain, uint8 bus)
 {
        PCIBus *newBus = new(std::nothrow) PCIBus;
        if (newBus == NULL)
@@ -1122,7 +1124,8 @@ PCI::_CreateBus(PCIDev *parent, int domain, uint8 bus)
 PCIDev *
 PCI::_CreateDevice(PCIBus *parent, uint8 device, uint8 function)
 {
-       FLOW("PCI: CreateDevice, domain %u, bus %u, dev %u, func %u:\n", 
parent->domain, parent->bus, device, function);
+       FLOW("PCI: CreateDevice, domain %u, bus %u, dev %u, func %u:\n", 
parent->domain,
+               parent->bus, device, function);
 
        PCIDev *newDev = new(std::nothrow) PCIDev;
        if (newDev == NULL)
@@ -1138,8 +1141,9 @@ PCI::_CreateDevice(PCIBus *parent, uint8 device, uint8 
function)
 
        _ReadBasicInfo(newDev);
 
-       FLOW("PCI: CreateDevice, vendor 0x%04x, device 0x%04x, class_base 
0x%02x, class_sub 0x%02x\n",
-               newDev->info.vendor_id, newDev->info.device_id, 
newDev->info.class_base, newDev->info.class_sub);
+       FLOW("PCI: CreateDevice, vendor 0x%04x, device 0x%04x, class_base 
0x%02x, "
+               "class_sub 0x%02x\n", newDev->info.vendor_id, 
newDev->info.device_id,
+               newDev->info.class_base, newDev->info.class_sub);
 
        // append
        if (parent->child == NULL) {
@@ -1451,7 +1455,7 @@ PCI::_RefreshDeviceInfo(PCIBus *bus)
 
 
 status_t
-PCI::ReadConfig(int domain, uint8 bus, uint8 device, uint8 function,
+PCI::ReadConfig(uint8 domain, uint8 bus, uint8 device, uint8 function,
        uint8 offset, uint8 size, uint32 *value)
 {
        domain_data *info = _GetDomainData(domain);
@@ -1474,7 +1478,7 @@ PCI::ReadConfig(int domain, uint8 bus, uint8 device, 
uint8 function,
 
 
 uint32
-PCI::ReadConfig(int domain, uint8 bus, uint8 device, uint8 function,
+PCI::ReadConfig(uint8 domain, uint8 bus, uint8 device, uint8 function,
        uint8 offset, uint8 size)
 {
        uint32 value;
@@ -1499,7 +1503,7 @@ PCI::ReadConfig(PCIDev *device, uint8 offset, uint8 size)
 
 
 status_t
-PCI::WriteConfig(int domain, uint8 bus, uint8 device, uint8 function,
+PCI::WriteConfig(uint8 domain, uint8 bus, uint8 device, uint8 function,
        uint8 offset, uint8 size, uint32 value)
 {
        domain_data *info = _GetDomainData(domain);
@@ -1530,7 +1534,7 @@ PCI::WriteConfig(PCIDev *device, uint8 offset, uint8 
size, uint32 value)
 
 
 status_t
-PCI::FindCapability(int domain, uint8 bus, uint8 device, uint8 function,
+PCI::FindCapability(uint8 domain, uint8 bus, uint8 device, uint8 function,
        uint8 capID, uint8 *offset)
 {
        if (offset == NULL) {
@@ -1597,14 +1601,14 @@ PCI::FindCapability(PCIDev *device, uint8 capID, uint8 
*offset)
 
 
 PCIDev *
-PCI::FindDevice(int domain, uint8 bus, uint8 device, uint8 function)
+PCI::FindDevice(uint8 domain, uint8 bus, uint8 device, uint8 function)
 {
        return _FindDevice(fRootBus, domain, bus, device, function);
 }
 
 
 PCIDev *
-PCI::_FindDevice(PCIBus *current, int domain, uint8 bus, uint8 device,
+PCI::_FindDevice(PCIBus *current, uint8 domain, uint8 bus, uint8 device,
        uint8 function)
 {
        if (current->domain == domain) {
@@ -1635,7 +1639,7 @@ PCI::_FindDevice(PCIBus *current, int domain, uint8 bus, 
uint8 device,
 
 
 status_t
-PCI::UpdateInterruptLine(int domain, uint8 bus, uint8 _device, uint8 function,
+PCI::UpdateInterruptLine(uint8 domain, uint8 bus, uint8 _device, uint8 
function,
        uint8 newInterruptLineValue)
 {
        PCIDev *device = FindDevice(domain, bus, _device, function);
diff --git a/src/add-ons/kernel/bus_managers/pci/pci.h 
b/src/add-ons/kernel/bus_managers/pci/pci.h
index a75fcfe..921aebc 100644
--- a/src/add-ons/kernel/bus_managers/pci/pci.h
+++ b/src/add-ons/kernel/bus_managers/pci/pci.h
@@ -34,7 +34,7 @@ struct PCIBus {
        PCIBus *                        next;
        PCIDev *                        parent;
        PCIDev *                        child;
-       int                                     domain;
+       uint8                           domain;
        uint8                           bus;
 };
 
@@ -42,7 +42,7 @@ struct PCIDev {
        PCIDev *                        next;
        PCIBus *                        parent;
        PCIBus *                        child;
-       int                                     domain;
+       uint8                           domain;
        uint8                           bus;
        uint8                           device;
        uint8                           function;
@@ -76,44 +76,45 @@ public:
 
                        status_t                GetNthInfo(long index, pci_info 
*outInfo);
 
-                       status_t                ReadConfig(int domain, uint8 
bus, uint8 device,
+                       status_t                ReadConfig(uint8 domain, uint8 
bus, uint8 device,
                                                                uint8 function, 
uint8 offset, uint8 size,
                                                                uint32 *value);
-                       uint32                  ReadConfig(int domain, uint8 
bus, uint8 device,
+                       uint32                  ReadConfig(uint8 domain, uint8 
bus, uint8 device,
                                                                uint8 function, 
uint8 offset, uint8 size);
                        uint32                  ReadConfig(PCIDev *device, 
uint8 offset,
                                                                uint8 size);
 
-                       status_t                WriteConfig(int domain, uint8 
bus, uint8 device,
+                       status_t                WriteConfig(uint8 domain, uint8 
bus, uint8 device,
                                                                uint8 function, 
uint8 offset, uint8 size,
                                                                uint32 value);
                        status_t                WriteConfig(PCIDev *device, 
uint8 offset,
                                                                uint8 size, 
uint32 value);
 
-                       status_t                FindCapability(int domain, 
uint8 bus, uint8 device,
-                                                               uint8 function, 
uint8 capID, uint8 *offset);
+                       status_t                FindCapability(uint8 domain, 
uint8 bus,
+                                                               uint8 device, 
uint8 function, uint8 capID,
+                                                               uint8 *offset);
                        status_t                FindCapability(PCIDev *device, 
uint8 capID,
                                                                uint8 *offset);
 
-                       status_t                ResolveVirtualBus(uint8 
virtualBus, int *domain,
+                       status_t                ResolveVirtualBus(uint8 
virtualBus, uint8 *domain,
                                                                uint8 *bus);
 
-                       PCIDev *                FindDevice(int domain, uint8 
bus, uint8 device,
+                       PCIDev *                FindDevice(uint8 domain, uint8 
bus, uint8 device,
                                                                uint8 function);
 
                        void                    ClearDeviceStatus(PCIBus *bus, 
bool dumpStatus);
 
                        void                    RefreshDeviceInfo();
 
-                       status_t                UpdateInterruptLine(int domain, 
uint8 bus,
+                       status_t                UpdateInterruptLine(uint8 
domain, uint8 bus,
                                                                uint8 device, 
uint8 function,
                                                                uint8 
newInterruptLineValue);
 
 private:
-                       void                    _EnumerateBus(int domain, uint8 
bus,
+                       void                    _EnumerateBus(uint8 domain, 
uint8 bus,
                                                                uint8 
*subordinateBus = NULL);
 
-                       void                    _FixupDevices(int domain, uint8 
bus);
+                       void                    _FixupDevices(uint8 domain, 
uint8 bus);
 
                        void                    _DiscoverBus(PCIBus *bus);
                        void                    _DiscoverDevice(PCIBus *bus, 
uint8 dev,
@@ -121,7 +122,8 @@ private:
 
                        PCIDev *                _CreateDevice(PCIBus *parent, 
uint8 dev,
                                                                uint8 function);
-                       PCIBus *                _CreateBus(PCIDev *parent, int 
domain, uint8 bus);
+                       PCIBus *                _CreateBus(PCIDev *parent, 
uint8 domain,
+                                                               uint8 bus);
 
                        status_t                _GetNthInfo(PCIBus *bus, long 
*currentIndex,
                                                                long wantIndex, 
pci_info *outInfo);
@@ -139,14 +141,15 @@ private:
                                                                uint32 
*address, uint32 *size = 0,
                                                                uint8 *flags = 
0);
 
-                       domain_data *   _GetDomainData(int domain);
+                       domain_data *   _GetDomainData(uint8 domain);
 
-                       status_t                _CreateVirtualBus(int domain, 
uint8 bus,
+                       status_t                _CreateVirtualBus(uint8 domain, 
uint8 bus,
                                                                uint8 
*virtualBus);
 
-                       int                             _NumFunctions(int 
domain, uint8 bus, uint8 device);
-                       PCIDev *                _FindDevice(PCIBus *current, 
int domain, uint8 bus,
-                                                               uint8 device, 
uint8 function);
+                       int                             _NumFunctions(uint8 
domain, uint8 bus,
+                                                               uint8 device);
+                       PCIDev *                _FindDevice(PCIBus *current, 
uint8 domain,
+                                                               uint8 bus, 
uint8 device, uint8 function);
 
 private:
        PCIBus *                                fRootBus;
@@ -154,7 +157,7 @@ private:
        enum { MAX_PCI_DOMAINS = 8 };
 
        domain_data                             fDomainData[MAX_PCI_DOMAINS];
-       int                                             fDomainCount;
+       uint8                                   fDomainCount;
        bool                                    fBusEnumeration;
 
        typedef VectorMap<uint8, uint16> VirtualBusMap;
@@ -182,7 +185,7 @@ uint32              pci_read_config(uint8 virtualBus, uint8 
device, uint8 function,
 void           pci_write_config(uint8 virtualBus, uint8 device, uint8 function,
                                uint8 offset, uint8 size, uint32 value);
 
-void           __pci_resolve_virtual_bus(uint8 virtualBus, int *domain, uint8 
*bus);
+void           __pci_resolve_virtual_bus(uint8 virtualBus, uint8 *domain, 
uint8 *bus);
 
 #ifdef __cplusplus
 }
diff --git a/src/add-ons/kernel/bus_managers/pci/pci_device.cpp 
b/src/add-ons/kernel/bus_managers/pci/pci_device.cpp
index 15c4566..32a885d 100644
--- a/src/add-ons/kernel/bus_managers/pci/pci_device.cpp
+++ b/src/add-ons/kernel/bus_managers/pci/pci_device.cpp
@@ -107,9 +107,9 @@ pci_device_get_pci_info(pci_device* device, struct 
pci_info* info)
 static status_t
 pci_device_init_driver(device_node* node, void** _cookie)
 {
-       uint32 domain;
+       uint8 domain;
        uint8 bus, deviceNumber, function;
-       if (gDeviceManager->get_attr_uint32(node, B_PCI_DEVICE_DOMAIN, &domain,
+       if (gDeviceManager->get_attr_uint8(node, B_PCI_DEVICE_DOMAIN, &domain,
                        false) != B_OK
                || gDeviceManager->get_attr_uint8(node, B_PCI_DEVICE_BUS, &bus,
                        false) != B_OK
diff --git a/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp 
b/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp
index 7ab20f6..d25e96f 100644
--- a/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp
+++ b/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp
@@ -22,7 +22,7 @@
  * the IDE driver for the AHCI controller for some reason).
  */
 static void
-jmicron_fixup_ahci(PCI *pci, int domain, uint8 bus, uint8 device,
+jmicron_fixup_ahci(PCI *pci, uint8 domain, uint8 bus, uint8 device,
        uint8 function, uint16 deviceId)
 {
        // We only care about function 0.
@@ -80,8 +80,8 @@ jmicron_fixup_ahci(PCI *pci, int domain, uint8 bus, uint8 
device,
 
 
 static void
-intel_fixup_ahci(PCI *pci, int domain, uint8 bus, uint8 device, uint8 function,
-       uint16 deviceId)
+intel_fixup_ahci(PCI *pci, uint8 domain, uint8 bus, uint8 device,
+       uint8 function, uint16 deviceId)
 {
        // TODO(bga): disabled until the PCI manager can assign new resources.
        return;
@@ -156,7 +156,8 @@ intel_fixup_ahci(PCI *pci, int domain, uint8 bus, uint8 
device, uint8 function,
 
 
 static void
-ati_fixup_ixp(PCI *pci, int domain, uint8 bus, uint8 device, uint8 function, 
uint16 deviceId)
+ati_fixup_ixp(PCI *pci, uint8 domain, uint8 bus, uint8 device, uint8 function,
+       uint16 deviceId)
 {
 #if defined(__INTEL__) || defined(__x86_64__)
        /* ATI Technologies Inc, IXP chipset:
@@ -187,7 +188,8 @@ ati_fixup_ixp(PCI *pci, int domain, uint8 bus, uint8 
device, uint8 function, uin
 
 
 void
-pci_fixup_device(PCI *pci, int domain, uint8 bus, uint8 device, uint8 function)
+pci_fixup_device(PCI *pci, uint8 domain, uint8 bus, uint8 device,
+       uint8 function)
 {
        uint16 vendorId = pci->ReadConfig(domain, bus, device, function,
                PCI_vendor_id, 2);
diff --git a/src/add-ons/kernel/bus_managers/pci/pci_fixup.h 
b/src/add-ons/kernel/bus_managers/pci/pci_fixup.h
index 9b6d1fb..418c7de 100644
--- a/src/add-ons/kernel/bus_managers/pci/pci_fixup.h
+++ b/src/add-ons/kernel/bus_managers/pci/pci_fixup.h
@@ -8,7 +8,8 @@
 
 class PCI;
 
-void
-pci_fixup_device(PCI *pci, int domain, uint8 bus, uint8 device, uint8 
function);
+
+void pci_fixup_device(PCI *pci, uint8 domain, uint8 bus, uint8 device,
+       uint8 function);
 
 #endif
diff --git a/src/add-ons/kernel/bus_managers/pci/pci_info.cpp 
b/src/add-ons/kernel/bus_managers/pci/pci_info.cpp
index ba748a0..ccc7ecf 100644
--- a/src/add-ons/kernel/bus_managers/pci/pci_info.cpp
+++ b/src/add-ons/kernel/bus_managers/pci/pci_info.cpp
@@ -179,7 +179,7 @@ print_capabilities(const pci_info *info)
 static void
 print_info_basic(const pci_info *info, bool verbose)
 {
-       int domain;
+       uint8 domain;
        uint8 bus;
 
        __pci_resolve_virtual_bus(info->bus, &domain, &bus);
diff --git a/src/add-ons/kernel/bus_managers/pci/pci_root.cpp 
b/src/add-ons/kernel/bus_managers/pci/pci_root.cpp
index fdb9530..84382fb 100644
--- a/src/add-ons/kernel/bus_managers/pci/pci_root.cpp
+++ b/src/add-ons/kernel/bus_managers/pci/pci_root.cpp
@@ -63,7 +63,7 @@ pci_root_register_child_devices(void* cookie)
 
        pci_info info;
        for (int32 i = 0; pci_get_nth_pci_info(i, &info) == B_OK; i++) {
-               int domain;
+               uint8 domain;
                uint8 bus;
                if (gPCI->ResolveVirtualBus(info.bus, &domain, &bus) != B_OK) {
 dprintf("FAILED!!!!\n");
@@ -75,7 +75,7 @@ dprintf("FAILED!!!!\n");
                        {B_DEVICE_BUS, B_STRING_TYPE, {string: "pci"}},
 
                        // location on PCI bus
-                       {B_PCI_DEVICE_DOMAIN, B_UINT32_TYPE, {ui32: domain}},
+                       {B_PCI_DEVICE_DOMAIN, B_UINT8_TYPE, {ui8: domain}},
                        {B_PCI_DEVICE_BUS, B_UINT8_TYPE, {ui8: bus}},
                        {B_PCI_DEVICE_DEVICE, B_UINT8_TYPE, {ui8: info.device}},
                        {B_PCI_DEVICE_FUNCTION, B_UINT8_TYPE, {ui8: 
info.function}},

############################################################################

Commit:      848acd672c1e1ee3cd9b18a3c746ca0c69bc567f
URL:         http://cgit.haiku-os.org/haiku/commit/?id=848acd6
Author:      Jérôme Duval <jerome.duval@xxxxxxxxx>
Date:        Fri Apr 26 17:59:30 2013 UTC

devfs: casts as size_t before comparing.

* error: comparison between signed and unsigned integer expressions.

----------------------------------------------------------------------------

diff --git a/src/system/kernel/device_manager/devfs.cpp 
b/src/system/kernel/device_manager/devfs.cpp
index 159fe39..7cc1ebc 100644
--- a/src/system/kernel/device_manager/devfs.cpp
+++ b/src/system/kernel/device_manager/devfs.cpp
@@ -487,7 +487,7 @@ translate_partition_access(devfs_partition* partition, 
off_t& offset,
        ASSERT(offset >= 0);
        ASSERT(offset < partition->info.size);
 
-       size = min_c(size, partition->info.size - offset);
+       size = min_c(size, (size_t)(partition->info.size - offset));
        offset += partition->info.offset;
 }
 

############################################################################

Commit:      44d2f5f53ecdbd030882fca45e40d53ea38801af
URL:         http://cgit.haiku-os.org/haiku/commit/?id=44d2f5f
Author:      Jérôme Duval <jerome.duval@xxxxxxxxx>
Date:        Fri Apr 26 18:10:51 2013 UTC

scsi bus manager: casts path_id to uint8.

* added a TODO about create_id() generating int32 ids when we need uint8.
* GCC 4.7 warning fixed: narrowing conversion.

----------------------------------------------------------------------------

diff --git a/src/add-ons/kernel/bus_managers/scsi/sim_interface.cpp 
b/src/add-ons/kernel/bus_managers/scsi/sim_interface.cpp
index bb4fa08..30b3fcc 100644
--- a/src/add-ons/kernel/bus_managers/scsi/sim_interface.cpp
+++ b/src/add-ons/kernel/bus_managers/scsi/sim_interface.cpp
@@ -27,7 +27,7 @@ static status_t
 scsi_controller_added(device_node *parent)
 {
        const char *controller_name;
-       int pathID;
+       int32 pathID;
 
        SHOW_FLOW0(4, "");
 
@@ -48,7 +48,8 @@ scsi_controller_added(device_node *parent)
                device_attr attrs[] = {
                        // remember who we are
                        // (could use the controller name, but probably some 
software would choke)
-                       { SCSI_BUS_PATH_ID_ITEM, B_UINT8_TYPE, { ui8: pathID }},
+                       // TODO create_id() generates a 32 bit ranged integer 
but we need only 8 bits
+                       { SCSI_BUS_PATH_ID_ITEM, B_UINT8_TYPE, { ui8: 
(uint8)pathID }},
 
                        // tell PnP manager to clean up ID
 //                     { PNP_MANAGER_ID_GENERATOR, B_STRING_TYPE, { string: 
SCSI_PATHID_GENERATOR }},

############################################################################

Commit:      5f08555a59523b2bcdd04bea9d14c497fc8ab01a
URL:         http://cgit.haiku-os.org/haiku/commit/?id=5f08555
Author:      Jérôme Duval <jerome.duval@xxxxxxxxx>
Date:        Fri Apr 26 18:10:23 2013 UTC

GCC 4.7.x doesn't allow writes in a referenced packed struct.

* error: cannot bind packed field 'image->preloaded_elf64_image::elf_header'
    to 'ELFLoader<ELF64Class>::EhdrType& {aka Elf64_Ehdr&}'

----------------------------------------------------------------------------

diff --git a/src/system/boot/loader/elf.cpp b/src/system/boot/loader/elf.cpp
index d12e3b1..7616e89 100644
--- a/src/system/boot/loader/elf.cpp
+++ b/src/system/boot/loader/elf.cpp
@@ -151,15 +151,15 @@ ELFLoader<Class>::Create(int fd, preloaded_image** _image)
        ImageType* image = (ImageType*)kernel_args_malloc(sizeof(ImageType));
        if (image == NULL)
                return B_NO_MEMORY;
-
-       EhdrType& elfHeader = image->elf_header;
-
-       ssize_t length = read_pos(fd, 0, &elfHeader, sizeof(EhdrType));
+       
+       ssize_t length = read_pos(fd, 0, &image->elf_header, sizeof(EhdrType));
        if (length < (ssize_t)sizeof(EhdrType)) {
                kernel_args_free(image);
                return B_BAD_TYPE;
        }
 
+       const EhdrType& elfHeader = image->elf_header;
+
        if (memcmp(elfHeader.e_ident, ELF_MAGIC, 4) != 0
                || elfHeader.e_ident[4] != Class::kIdentClass
                || elfHeader.e_phoff == 0
@@ -186,7 +186,7 @@ ELFLoader<Class>::Load(int fd, preloaded_image* _image)
        void* mappedRegion = NULL;
 
        ImageType* image = static_cast<ImageType*>(_image);
-       EhdrType& elfHeader = image->elf_header;
+       const EhdrType& elfHeader = image->elf_header;
 
        ssize_t size = elfHeader.e_phnum * elfHeader.e_phentsize;
        PhdrType* programHeaders = (PhdrType*)malloc(size);
@@ -445,7 +445,7 @@ template<typename Class>
 /*static*/ status_t
 ELFLoader<Class>::_LoadSymbolTable(int fd, ImageType* image)
 {
-       EhdrType& elfHeader = image->elf_header;
+       const EhdrType& elfHeader = image->elf_header;
        SymType* symbolTable = NULL;
        ShdrType* stringHeader = NULL;
        uint32 numSymbols = 0;

############################################################################

Commit:      cc3fb1f518747bb9b897b3868cc89577261a2e47
URL:         http://cgit.haiku-os.org/haiku/commit/?id=cc3fb1f
Author:      Jérôme Duval <jerome.duval@xxxxxxxxx>
Date:        Fri Apr 26 18:11:53 2013 UTC

icon-o-matic: converts the result of round() to uint8 to fit in struct 
rgb_color.

* GCC 4.7 warning: narrowing conversion of 
'(int)(((ColorPickerView*)this)->ColorPickerView::r * 2.55e+2f)'
from 'int' to 'uint8 {aka unsigned char}' inside { } is ill-formed in C++11 
[-Werror=narrowing]

----------------------------------------------------------------------------

diff --git 
a/src/apps/icon-o-matic/generic/gui/panel/color_picker/ColorField.cpp 
b/src/apps/icon-o-matic/generic/gui/panel/color_picker/ColorField.cpp
index 93aae00..7ddbde7 100644
--- a/src/apps/icon-o-matic/generic/gui/panel/color_picker/ColorField.cpp
+++ b/src/apps/icon-o-matic/generic/gui/panel/color_picker/ColorField.cpp
@@ -315,7 +315,8 @@ ColorField::SetModeAndValue(selected_color_mode mode, float 
fixed_value)
                R *= 255.0; G *= 255.0; B *= 255.0;
        }
        
-       rgb_color color = { round(R), round(G), round(B), 255 };
+       rgb_color color = { (uint8)round(R), (uint8)round(G), (uint8)round(B),
+               255 };
 
        fBgBitmap[0]->Unlock();
 
diff --git 
a/src/apps/icon-o-matic/generic/gui/panel/color_picker/ColorPickerView.cpp 
b/src/apps/icon-o-matic/generic/gui/panel/color_picker/ColorPickerView.cpp
index 4633d2e..d4c7b45 100644
--- a/src/apps/icon-o-matic/generic/gui/panel/color_picker/ColorPickerView.cpp
+++ b/src/apps/icon-o-matic/generic/gui/panel/color_picker/ColorPickerView.cpp
@@ -82,7 +82,8 @@ ColorPickerView::layout(BRect frame)
 void
 ColorPickerView::AttachedToWindow()
 {
-       rgb_color       color = { (int)(r * 255), (int)(g * 255), (int)(b * 
255), 255 };
+       rgb_color color = { (uint8)(r * 255), (uint8)(g * 255), (uint8)(b * 
255),
+               255 };
 
        BView::AttachedToWindow();
 
@@ -266,7 +267,8 @@ ColorPickerView::MessageReceived(BMessage *message)
                                HSV_to_RGB(h, s, v, r, g, b);
                        }
 
-                       rgb_color color = { round(r*255), round(g*255), 
round(b*255), 255 };
+                       rgb_color color = { (uint8)round(r * 255), 
(uint8)round(g * 255),
+                               (uint8)round(b * 255), 255 };
 
                        SetColor(color);
                        
@@ -275,7 +277,8 @@ ColorPickerView::MessageReceived(BMessage *message)
                case MSG_HEXTEXTCONTROL: {
                        if (fHexTextControl->TextView()->TextLength()==6) {
                                const char *string = 
fHexTextControl->TextView()->Text();
-                               rgb_color color = { hexdec(string, 0), 
hexdec(string, 2), hexdec(string, 4), 255 };
+                               rgb_color color = { (uint8)hexdec(string, 0), 
(uint8)hexdec(string, 2),
+                                       (uint8)hexdec(string, 4), 255 };
                                SetColor(color);
                        }
                } break;
@@ -449,7 +452,8 @@ ColorPickerView::_UpdateColor(float value, float value1, 
float value2)
        else
                HSV_to_RGB(h, s, v, r, g, b);
 
-       rgb_color color = { (int)(r*255), (int)(g*255), (int)(b*255), 255 };
+       rgb_color color = { (uint8)round(r * 255), (uint8)round(g*255),
+               (uint8)round(b * 255), 255 };
        fColorPreview->SetColor(color);
 }
 

############################################################################

Revision:    hrev45558
Commit:      f7176b0ee50d5367762d904a943a693b0a8e3e2f
URL:         http://cgit.haiku-os.org/haiku/commit/?id=f7176b0
Author:      Jérôme Duval <jerome.duval@xxxxxxxxx>
Date:        Fri Apr 26 18:45:53 2013 UTC

VMAnonymousCache.cpp: changed page_index type to page_num_t

* consistently use page_num_t for page numbers and off_t for offsets and sizes.

----------------------------------------------------------------------------

diff --git a/src/system/kernel/vm/VMAnonymousCache.cpp 
b/src/system/kernel/vm/VMAnonymousCache.cpp
index 8302f99..ed2161f 100644
--- a/src/system/kernel/vm/VMAnonymousCache.cpp
+++ b/src/system/kernel/vm/VMAnonymousCache.cpp
@@ -96,7 +96,7 @@ struct swap_file : DoublyLinkedListLinkImpl<swap_file> {
 
 struct swap_hash_key {
        VMAnonymousCache        *cache;
-       off_t                           page_index;  // page index in the cache
+       page_num_t                      page_index;  // page index in the cache
 };
 
 // Each swap block contains swap address information for
@@ -128,8 +128,8 @@ struct SwapHashTableDefinition {
 
        bool Compare(const swap_hash_key& key, const swap_block* value) const
        {
-               return (key.page_index & ~(off_t)SWAP_BLOCK_MASK)
-                               == (value->key.page_index & 
~(off_t)SWAP_BLOCK_MASK)
+               return (key.page_index & ~(page_num_t)SWAP_BLOCK_MASK)
+                               == (value->key.page_index & 
~(page_num_t)SWAP_BLOCK_MASK)
                        && key.cache == value->key.cache;
        }
 
@@ -557,7 +557,7 @@ VMAnonymousCache::Commit(off_t size, int priority)
 
                // pre-commit some pages to make a later failure less probable
                fHasPrecommitted = true;
-               uint32 precommitted = fPrecommittedPages * B_PAGE_SIZE;
+               off_t precommitted = (off_t)fPrecommittedPages * B_PAGE_SIZE;
                if (size > precommitted)
                        size = precommitted;
        }
@@ -593,7 +593,7 @@ status_t
 VMAnonymousCache::Read(off_t offset, const generic_io_vec* vecs, size_t count,
        uint32 flags, generic_size_t* _numBytes)
 {
-       off_t pageIndex = offset >> PAGE_SHIFT;
+       page_num_t pageIndex = offset >> PAGE_SHIFT;
 
        for (uint32 i = 0, j = 0; i < count; i = j) {
                swap_addr_t startSlotIndex = _SwapBlockGetAddress(pageIndex + 
i);
@@ -625,7 +625,7 @@ status_t
 VMAnonymousCache::Write(off_t offset, const generic_io_vec* vecs, size_t count,
        uint32 flags, generic_size_t* _numBytes)
 {
-       off_t pageIndex = offset >> PAGE_SHIFT;
+       page_num_t pageIndex = offset >> PAGE_SHIFT;
 
        AutoLocker<VMCache> locker(this);
 
@@ -636,13 +636,13 @@ VMAnonymousCache::Write(off_t offset, const 
generic_io_vec* vecs, size_t count,
                if (slotIndex != SWAP_SLOT_NONE) {
                        swap_slot_dealloc(slotIndex, pageCount);
                        _SwapBlockFree(pageIndex + totalPages, pageCount);
-                       fAllocatedSwapSize -= pageCount * B_PAGE_SIZE;
+                       fAllocatedSwapSize -= (off_t)pageCount * B_PAGE_SIZE;
                }
 
                totalPages += pageCount;
        }
 
-       off_t totalSize = totalPages * B_PAGE_SIZE;
+       off_t totalSize = (off_t)totalPages * B_PAGE_SIZE;
        if (fAllocatedSwapSize + totalSize > fCommittedSwapSize)
                return B_ERROR;
 
@@ -695,8 +695,8 @@ VMAnonymousCache::Write(off_t offset, const generic_io_vec* 
vecs, size_t count,
                        pagesLeft -= n;
 
                        if (n != pageCount) {
-                               vectorBase = vectorBase + n * B_PAGE_SIZE;
-                               vectorLength -= n * B_PAGE_SIZE;
+                               vectorBase = vectorBase + (off_t)n * 
B_PAGE_SIZE;
+                               vectorLength -= (off_t)n * B_PAGE_SIZE;
                        }
                }
 
@@ -818,7 +818,7 @@ VMAnonymousCache::Fault(struct VMAddressSpace* aspace, 
off_t offset)
                                        ? VM_PRIORITY_SYSTEM : VM_PRIORITY_USER;
                                if (vm_try_reserve_memory(B_PAGE_SIZE, 
priority, 0) != B_OK) {
                                        dprintf("%p->VMAnonymousCache::Fault(): 
Failed to reserve "
-                                               "%d bytes of RAM.\n", this, 
(int)B_PAGE_SIZE);
+                                               "%d bytes of RAM.\n", this, 
B_PAGE_SIZE);
                                        return B_NO_MEMORY;
                                }
                        }
@@ -873,14 +873,14 @@ VMAnonymousCache::DeleteObject()
 
 
 void
-VMAnonymousCache::_SwapBlockBuild(off_t startPageIndex,
+VMAnonymousCache::_SwapBlockBuild(page_num_t startPageIndex,
        swap_addr_t startSlotIndex, uint32 count)
 {
        WriteLocker locker(sSwapHashLock);
 
        uint32 left = count;
        for (uint32 i = 0, j = 0; i < count; i += j) {
-               off_t pageIndex = startPageIndex + i;
+               page_num_t pageIndex = startPageIndex + i;
                swap_addr_t slotIndex = startSlotIndex + i;
 
                swap_hash_key key = { this, pageIndex };
@@ -899,7 +899,7 @@ VMAnonymousCache::_SwapBlockBuild(off_t startPageIndex,
                        }
 
                        swap->key.cache = this;
-                       swap->key.page_index = pageIndex & 
~(off_t)SWAP_BLOCK_MASK;
+                       swap->key.page_index = pageIndex & 
~(page_num_t)SWAP_BLOCK_MASK;
                        swap->used = 0;
                        for (uint32 i = 0; i < SWAP_BLOCK_PAGES; i++)
                                swap->swap_slots[i] = SWAP_SLOT_NONE;
@@ -919,13 +919,13 @@ VMAnonymousCache::_SwapBlockBuild(off_t startPageIndex,
 
 
 void
-VMAnonymousCache::_SwapBlockFree(off_t startPageIndex, uint32 count)
+VMAnonymousCache::_SwapBlockFree(page_num_t startPageIndex, uint32 count)
 {
        WriteLocker locker(sSwapHashLock);
 
        uint32 left = count;
        for (uint32 i = 0, j = 0; i < count; i += j) {
-               off_t pageIndex = startPageIndex + i;
+               page_num_t pageIndex = startPageIndex + i;
                swap_hash_key key = { this, pageIndex };
                swap_block* swap = sSwapHashTable.Lookup(key);
 
@@ -948,7 +948,7 @@ VMAnonymousCache::_SwapBlockFree(off_t startPageIndex, 
uint32 count)
 
 
 swap_addr_t
-VMAnonymousCache::_SwapBlockGetAddress(off_t pageIndex)
+VMAnonymousCache::_SwapBlockGetAddress(page_num_t pageIndex)
 {
        ReadLocker locker(sSwapHashLock);
 
@@ -1127,7 +1127,7 @@ VMAnonymousCache::_MergeSwapPages(VMAnonymousCache* 
source)
                        continue;
 
                for (uint32 i = 0; i < SWAP_BLOCK_PAGES; i++) {
-                       off_t pageIndex = swapBlockPageIndex + i;
+                       page_num_t pageIndex = swapBlockPageIndex + i;
                        swap_addr_t sourceSlotIndex = 
sourceSwapBlock->swap_slots[i];
 
                        if (sourceSlotIndex == SWAP_SLOT_NONE)
@@ -1318,7 +1318,7 @@ swap_file_add(const char* path)
        swap->vnode = node;
        swap->cookie = descriptor->cookie;
 
-       uint32 pageCount = st.st_size >> PAGE_SHIFT;
+       page_num_t pageCount = st.st_size >> PAGE_SHIFT;
        swap->bmp = radix_bitmap_create(pageCount);
        if (swap->bmp == NULL) {
                free(swap);
@@ -1635,18 +1635,18 @@ swap_free_page_swap_space(vm_page* page)
 }
 
 
-uint32
+page_num_t
 swap_available_pages()
 {
        mutex_lock(&sAvailSwapSpaceLock);
-       uint32 avail = sAvailSwapSpace >> PAGE_SHIFT;
+       page_num_t avail = sAvailSwapSpace >> PAGE_SHIFT;
        mutex_unlock(&sAvailSwapSpaceLock);
 
        return avail;
 }
 
 
-uint32
+page_num_t
 swap_total_swap_pages()
 {
        mutex_lock(&sSwapFileListLock);
diff --git a/src/system/kernel/vm/VMAnonymousCache.h 
b/src/system/kernel/vm/VMAnonymousCache.h
index 065f422..26ff9b7 100644
--- a/src/system/kernel/vm/VMAnonymousCache.h
+++ b/src/system/kernel/vm/VMAnonymousCache.h
@@ -25,8 +25,8 @@ extern "C" {
        void swap_init(void);
        void swap_init_post_modules(void);
        bool swap_free_page_swap_space(vm_page* page);
-       uint32 swap_available_pages(void);
-       uint32 swap_total_swap_pages(void);
+       page_num_t swap_available_pages(void);
+       page_num_t swap_total_swap_pages(void);
 }
 
 
@@ -73,10 +73,10 @@ private:
                        class WriteCallback;
                        friend class WriteCallback;
 
-                       void                            _SwapBlockBuild(off_t 
pageIndex,
+                       void                            
_SwapBlockBuild(page_num_t pageIndex,
                                                                        
swap_addr_t slotIndex, uint32 count);
-                       void                    _SwapBlockFree(off_t pageIndex, 
uint32 count);
-                       swap_addr_t                     
_SwapBlockGetAddress(off_t pageIndex);
+                       void                    _SwapBlockFree(page_num_t 
pageIndex, uint32 count);
+                       swap_addr_t                     
_SwapBlockGetAddress(page_num_t pageIndex);
                        status_t                        _Commit(off_t size, int 
priority);
 
                        void                            
_MergePagesSmallerSource(


Other related posts: