Removed the addr_t conversion operators from FixedWidthPointer which makes comparison against NULL work properly.

This commit is contained in:
Alex Smith
2012-06-22 18:22:11 +01:00
parent 474aa3b76e
commit 62d36f9833
12 changed files with 30 additions and 26 deletions
+14 -10
View File
@@ -25,11 +25,6 @@ public:
return (Type *)(addr_t)fValue;
}
operator addr_t() const
{
return (addr_t)fValue;
}
Type& operator*() const
{
return *(Type *)*this;
@@ -90,11 +85,6 @@ public:
return (OtherType*)(addr_t)fValue;
}
operator addr_t() const
{
return (addr_t)fValue;
}
FixedWidthPointer& operator=(const FixedWidthPointer& p)
{
fValue = p.fValue;
@@ -121,5 +111,19 @@ private:
uint64 fValue;
} _PACKED;
template<typename Type>
inline bool
operator==(const FixedWidthPointer<Type>& a, void* b)
{
return a.Get() == (addr_t)b;
}
template<typename Type>
inline bool
operator!=(const FixedWidthPointer<Type>& a, void* b)
{
return a.Get() != (addr_t)b;
}
#endif /* KERNEL_UTIL_FIXED_WIDTH_POINTER_H */
+1 -1
View File
@@ -162,7 +162,7 @@ debug_cleanup(void)
if (!gKernelArgs.keep_debug_output_buffer) {
gKernelArgs.debug_output = kernel_args_malloc(sBufferPosition);
if (gKernelArgs.debug_output) {
if (gKernelArgs.debug_output != NULL) {
memcpy(gKernelArgs.debug_output, sBuffer, sBufferPosition);
gKernelArgs.debug_size = sBufferPosition;
}
+3 -3
View File
@@ -60,21 +60,21 @@ static int smp_get_current_cpu(void);
static uint32
apic_read(uint32 offset)
{
return *(volatile uint32 *)((addr_t)gKernelArgs.arch_args.apic + offset);
return *(volatile uint32 *)((addr_t)(void *)gKernelArgs.arch_args.apic + offset);
}
static void
apic_write(uint32 offset, uint32 data)
{
*(volatile uint32 *)((addr_t)gKernelArgs.arch_args.apic + offset) = data;
*(volatile uint32 *)((addr_t)(void *)gKernelArgs.arch_args.apic + offset) = data;
}
static int
smp_get_current_cpu(void)
{
if (!gKernelArgs.arch_args.apic)
if (gKernelArgs.arch_args.apic == NULL)
return 0;
uint8 apicID = apic_read(APIC_ID) >> 24;
+1 -1
View File
@@ -957,7 +957,7 @@ platform_init_video(void)
}
gKernelArgs.edid_info = kernel_args_malloc(sizeof(edid1_info));
if (gKernelArgs.edid_info)
if (gKernelArgs.edid_info != NULL)
memcpy(gKernelArgs.edid_info, &info, sizeof(edid1_info));
}
@@ -146,7 +146,7 @@ video_display_splash(addr_t frameBuffer)
// pointer into the lower half of the icons image data
gKernelArgs.boot_splash
= (uint8*)kernel_args_malloc(uncompressedSize);
if (!gKernelArgs.boot_splash)
if (gKernelArgs.boot_splash == NULL)
return B_NO_MEMORY;
uncompress(kSplashIcons8BitCompressedImage,
sizeof(kSplashIcons8BitCompressedImage),
@@ -159,7 +159,7 @@ video_display_splash(addr_t frameBuffer)
// pointer into the lower half of the icons image data
gKernelArgs.boot_splash
= (uint8*)kernel_args_malloc(uncompressedSize);
if (!gKernelArgs.boot_splash)
if (gKernelArgs.boot_splash == NULL)
return B_NO_MEMORY;
uncompress(kSplashIcons24BitCompressedImage,
sizeof(kSplashIcons24BitCompressedImage),
@@ -126,7 +126,7 @@ platform_init_video(void)
edid_dump(&info);
#endif
gKernelArgs.edid_info = kernel_args_malloc(sizeof(edid1_info));
if (gKernelArgs.edid_info)
if (gKernelArgs.edid_info != NULL)
memcpy(gKernelArgs.edid_info, &info, sizeof(edid1_info));
}
+1 -1
View File
@@ -83,7 +83,7 @@ serial_cleanup(void)
return;
gKernelArgs.debug_output = kernel_args_malloc(sBufferPosition);
if (gKernelArgs.debug_output) {
if (gKernelArgs.debug_output != NULL) {
memcpy(gKernelArgs.debug_output, sBuffer, sBufferPosition);
gKernelArgs.debug_size = sBufferPosition;
}
+1 -1
View File
@@ -68,7 +68,7 @@ apic_disable_local_ints()
status_t
apic_init(kernel_args *args)
{
if (!args->arch_args.apic)
if (args->arch_args.apic == NULL)
return B_NO_INIT;
sLocalAPIC = args->arch_args.apic;
+1 -1
View File
@@ -650,7 +650,7 @@ ioapic_init(kernel_args* args)
&ioapic_end_of_interrupt
};
if (!args->arch_args.apic)
if (args->arch_args.apic == NULL)
return;
if (args->arch_args.ioapic_phys == 0) {
@@ -217,7 +217,7 @@ hpet_init(struct kernel_args *args)
/* hpet_acpi_probe() through a similar "scan spots" table
to that of smp.cpp.
Seems to be the most elegant solution right now. */
if (!args->arch_args.hpet)
if (args->arch_args.hpet == NULL)
return B_ERROR;
if (sHPETRegs == NULL) {
+3 -3
View File
@@ -1384,7 +1384,7 @@ syslog_init_post_vm(struct kernel_args* args)
}
} else {
// create an area for the debug syslog buffer
void* base = (void*)ROUNDDOWN((addr_t)args->debug_output, B_PAGE_SIZE);
void* base = (void*)ROUNDDOWN((addr_t)(void *)args->debug_output, B_PAGE_SIZE);
size_t size = ROUNDUP(args->debug_size, B_PAGE_SIZE);
area_id area = create_area("syslog debug", &base, B_EXACT_ADDRESS, size,
B_ALREADY_WIRED, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
@@ -1401,7 +1401,7 @@ syslog_init_post_vm(struct kernel_args* args)
sSyslogMessage->ident[0] = '\0';
//strcpy(sSyslogMessage->ident, "KERNEL");
if (args->debug_output)
if (args->debug_output != NULL)
syslog_write((const char*)args->debug_output, args->debug_size, false);
char revisionBuffer[64];
@@ -1431,7 +1431,7 @@ err1:
static status_t
syslog_init(struct kernel_args* args)
{
if (!args->keep_debug_output_buffer || !args->debug_output)
if (!args->keep_debug_output_buffer || args->debug_output == NULL)
return B_OK;
sSyslogBuffer = create_ring_buffer_etc(args->debug_output, args->debug_size,
@@ -442,7 +442,7 @@ frame_buffer_console_init(kernel_args* args)
add_boot_item(VESA_MODES_BOOT_INFO, sVesaModes, args->vesa_modes_size);
}
if (args->edid_info) {
if (args->edid_info != NULL) {
edid1_info* info = (edid1_info*)malloc(sizeof(edid1_info));
if (info != NULL) {
memcpy(info, args->edid_info, sizeof(edid1_info));