Unverified Commit 15363c52 authored by PhoeniX's avatar PhoeniX

Static analyser warnings fix

parent 9c4f6eac
......@@ -299,7 +299,7 @@ struct EFI_CONFIGURATION_TABLE {
const void *VendorTable;
};
static inline bool operator ==(const EFI_GUID lhs, const EFI_GUID rhs) {
static inline bool operator ==(const EFI_GUID &lhs, const EFI_GUID &rhs) {
return
lhs.Data1 == rhs.Data1 &&
lhs.Data2 == rhs.Data2 &&
......
......@@ -21,6 +21,7 @@ class ConsoleDisplay: public Display {
do {
*(display++) = ' ';
*(display++) = 0x0F;
pos += 2;
} while (pos % 8 != 0);
} else {
*(display++) = c;
......@@ -67,8 +68,7 @@ class FramebufferDisplay: public Display {
size_t pixelBytes() {
switch (pixelFormat) {
case PixelFormatRGBX: return 4;
case PixelFormatBGRX: return 4;
case PixelFormatRGBX: case PixelFormatBGRX: return 4;
}
return 0;
}
......@@ -89,12 +89,12 @@ class FramebufferDisplay: public Display {
size_t offsetY = offset / charWidth();
size_t pb = pixelBytes();
char *fbptr = static_cast<char*>(framebuffer)
uint8_t *fbptr = static_cast<uint8_t*>(framebuffer)
+ offsetY * 16 * width * pb
+ offsetX * 8 * pb;
for (size_t y = 0; y < 16; y++) {
char *line = fbptr + y * width * pb;
uint8_t *line = fbptr + y * width * pb;
uint8_t fontline = fontsym[y];
for (size_t x = 0; x < 8; x++) {
if (fontline & (1 << (8 - x))) {
......
......@@ -21,7 +21,7 @@ class List {
return items[count++];
}
void add(const Item item) { insert() = item; }
void add(const Item &item) { insert() = item; }
size_t getCount() { return count; }
......
......@@ -84,7 +84,7 @@ ACPI::ACPI() {
LapicOut(LAPIC_TMRINITCNT, -1);
while ((inportb(0x61) & 0x20) == (t & 0x20)) {}
LapicOut(LAPIC_LVT_TMR, LAPIC_DISABLE);
busfreq = ((-1 - LapicIn(LAPIC_TMRCURRCNT)) << 4) * 100;
busfreq = (static_cast<uint64_t>(-1 - LapicIn(LAPIC_TMRCURRCNT)) << 4) * 100;
}
void ACPI::ParseDT(const AcpiHeader *header) {
Pagetable::map(header);
......@@ -119,7 +119,7 @@ void ACPI::ParseXsdt(const AcpiHeader *xsdt) {
void ACPI::ParseApic(const AcpiMadt *madt) {
Pagetable::map(madt);
localApicAddr = reinterpret_cast<char*>(madt->localApicAddr);
localApicAddr = reinterpret_cast<char*>(uintptr_t(madt->localApicAddr));
Pagetable::map(localApicAddr);
const uint8_t *p = reinterpret_cast<const uint8_t*>(madt + 1);
......@@ -137,7 +137,7 @@ void ACPI::ParseApic(const AcpiMadt *madt) {
acpiCpuIds[acpiCpuCount++] = s->apicId;
} else if (type == 1) {
const ApicIoApic *s = reinterpret_cast<const ApicIoApic*>(p);
ioApicAddr = reinterpret_cast<char*>(s->ioApicAddress);
ioApicAddr = reinterpret_cast<char*>(uintptr_t(s->ioApicAddress));
Pagetable::map(ioApicAddr);
} else if (type == 2) {
const ApicInterruptOverride *s =
......@@ -171,7 +171,7 @@ bool ACPI::ParseRsdp(const void *ptr) {
Pagetable::map(rsdtPtr + 1);
uint32_t rsdtAddr = *rsdtPtr;
if (revision == 0) {
ParseRsdt(reinterpret_cast<AcpiHeader*>(rsdtAddr));
ParseRsdt(reinterpret_cast<AcpiHeader*>(uintptr_t(rsdtAddr)));
} else if (revision == 2) {
Pagetable::map(xsdtPtr);
Pagetable::map(xsdtPtr + 1);
......@@ -180,7 +180,7 @@ bool ACPI::ParseRsdp(const void *ptr) {
if (xsdtAddr)
ParseXsdt(reinterpret_cast<AcpiHeader*>(xsdtAddr));
else
ParseRsdt(reinterpret_cast<AcpiHeader*>(rsdtAddr));
ParseRsdt(reinterpret_cast<AcpiHeader*>(uintptr_t(rsdtAddr)));
}
return true;
......
......@@ -172,19 +172,19 @@ char* CPU::getFeaturesStr() {
char *end = buf;
for (int i = 0; i < 64; i++) {
if (((f & (1 << i)) != 0) && CPUID_FEAT_STR[i][0]) {
if (((f & (1ll << i)) != 0) && CPUID_FEAT_STR[i][0]) {
end += snprintf(end, bufsize - (end - buf), "%s ", CPUID_FEAT_STR[i]);
}
}
for (int i = 0; i < 64; i++) {
if (((ef & (1 << i)) != 0) && CPUID_EXT_FEAT_STR[i][0]) {
if (((ef & (1ll << i)) != 0) && CPUID_EXT_FEAT_STR[i][0]) {
end += snprintf(end, bufsize - (end - buf), "%s ", CPUID_EXT_FEAT_STR[i]);
}
}
for (int i = 0; i < 64; i++) {
if (((fe & (1 << i)) != 0) && CPUID_FEAT_EXT_STR[i][0]) {
if (((fe & (1ll << i)) != 0) && CPUID_FEAT_EXT_STR[i][0]) {
end += snprintf(end, bufsize - (end - buf), "%s ", CPUID_FEAT_EXT_STR[i]);
}
}
......
......@@ -10,15 +10,15 @@ PTE *Pagetable::pagetable;
Mutex Pagetable::page_mutex;
uintptr_t Pagetable::last_page = 1;
static void fillPages(uintptr_t low, uintptr_t top, PTE *pagetable) {
static void fillPages(uintptr_t low, uintptr_t top, PTE *pagetable, uint8_t flags = 3) {
low &= 0xFFFFFFFFFFFFF000;
top = ALIGN(top, 0x1000);
for (; low < top; low += 0x1000)
*PTE::find(low, pagetable) = PTE(low, 3);
*PTE::find(low, pagetable) = PTE(low, flags);
}
static inline void fillPages(void *low, void *top, PTE *pagetable) {
fillPages(uintptr_t(low), uintptr_t(top), pagetable);
static inline void fillPages(void *low, void *top, PTE *pagetable, uint8_t flags = 3) {
fillPages(uintptr_t(low), uintptr_t(top), pagetable, flags);
}
static void *efiAllocatePage(uintptr_t min, const EFI_SYSTEM_TABLE *ST) {
......@@ -33,13 +33,11 @@ static void *efiAllocatePage(uintptr_t min, const EFI_SYSTEM_TABLE *ST) {
map = static_cast<EFI_MEMORY_DESCRIPTOR*>(alloca(mapSize));
ST->BootServices->GetMemoryMap(&mapSize, map, &mapKey, &entSize, &entVer);
for (ent = map;
ent < reinterpret_cast<EFI_MEMORY_DESCRIPTOR*>(
uintptr_t(map) + mapSize);
ent = reinterpret_cast<EFI_MEMORY_DESCRIPTOR*>(
uintptr_t(ent) + entSize)) {
ent < reinterpret_cast<EFI_MEMORY_DESCRIPTOR*>(uintptr_t(map) + mapSize);
ent = reinterpret_cast<EFI_MEMORY_DESCRIPTOR*>(uintptr_t(ent) + entSize)) {
if (ent->Type != EFI_MEMORY_TYPE_CONVENTIONAL) continue;
if (ent->PhysicalStart + ent->NumberOfPages * 0x1000 <= min) continue;
ptr = reinterpret_cast<void*>(MAX(min, ent->PhysicalStart));
ptr = reinterpret_cast<void*>(MAX(min, uintptr_t(ent->PhysicalStart)));
break;
}
ST->BootServices->AllocatePages(
......@@ -50,7 +48,7 @@ static void *efiAllocatePage(uintptr_t min, const EFI_SYSTEM_TABLE *ST) {
}
static void efiMapPage(PTE *pagetable, const void *page,
const EFI_SYSTEM_TABLE *ST) {
const EFI_SYSTEM_TABLE *ST, uint8_t flags = 3) {
uintptr_t ptr = uintptr_t(page), min = uintptr_t(pagetable);
uint64_t ptx = (ptr >> (12 + 9*3)) & 0x1FF;
uint64_t pdx = (ptr >> (12 + 9*2)) & 0x1FF;
......@@ -73,7 +71,7 @@ static void efiMapPage(PTE *pagetable, const void *page,
efiMapPage(pagetable, pdpe->getPtr(), ST);
}
PTE *pml4e = pdpe->getPTE() + pml4x;
*pml4e = PTE(page, 3);
*pml4e = PTE(page, flags);
}
void Pagetable::init() {
......@@ -116,10 +114,8 @@ void Pagetable::init() {
map = static_cast<EFI_MEMORY_DESCRIPTOR*>(alloca(mapSize));
ST->BootServices->GetMemoryMap(&mapSize, map, &mapKey, &entSize, &entVer);
for (ent = map;
ent < reinterpret_cast<EFI_MEMORY_DESCRIPTOR*>(
uintptr_t(map) + mapSize);
ent = reinterpret_cast<EFI_MEMORY_DESCRIPTOR*>(
uintptr_t(ent) + entSize)) {
ent < reinterpret_cast<EFI_MEMORY_DESCRIPTOR*>(uintptr_t(map) + mapSize);
ent = reinterpret_cast<EFI_MEMORY_DESCRIPTOR*>(uintptr_t(ent) + entSize)) {
if (ent->Type == EFI_MEMORY_TYPE_CONVENTIONAL) continue;
for (uintptr_t ptr = ent->PhysicalStart;
ptr < ent->PhysicalStart + ent->NumberOfPages * 0x1000;
......@@ -169,7 +165,7 @@ void Pagetable::init() {
if (multiboot->flags & MB_FLAG_CMDLINE) {
if (multiboot->pcmdline < 0x80000)
multiboot->pcmdline += uintptr_t(bss_top);
map(reinterpret_cast<void*>(multiboot->pcmdline));
map(reinterpret_cast<void*>(uintptr_t(multiboot->pcmdline)));
}
if (multiboot->flags & MB_FLAG_MODS) {
......@@ -185,7 +181,7 @@ void Pagetable::init() {
map(reinterpret_cast<void*>(addr));
const MULTIBOOT_MODULE *mods =
reinterpret_cast<MULTIBOOT_MODULE*>(multiboot->pmods_addr);
reinterpret_cast<MULTIBOOT_MODULE*>(uintptr_t(multiboot->pmods_addr));
for (uint32_t i = 0; i < multiboot->mods_count; i++) {
uintptr_t low = mods[i].start;
uintptr_t top = ALIGN(mods[i].end, 0x1000);
......@@ -198,7 +194,7 @@ void Pagetable::init() {
if (multiboot->pmmap_addr < 0x80000)
multiboot->pmmap_addr += uintptr_t(bss_top);
const char *mmap = reinterpret_cast<const char*>(multiboot->pmmap_addr);
const char *mmap = reinterpret_cast<const char*>(uintptr_t(multiboot->pmmap_addr));
const char *mmap_top = mmap + multiboot->mmap_length;
while (mmap < mmap_top) {
const MULTIBOOT_MMAP_ENT *ent =
......
......@@ -85,10 +85,10 @@ void ModuleManager::parseInitRD() {
MULTIBOOT_PAYLOAD *multiboot = Multiboot::getPayload();
if (!multiboot || (multiboot->flags & MB_FLAG_MODS) == 0) return;
const MULTIBOOT_MODULE *mods =
reinterpret_cast<const MULTIBOOT_MODULE*>(multiboot->pmods_addr);
reinterpret_cast<const MULTIBOOT_MODULE*>(uintptr_t(multiboot->pmods_addr));
for (uint32_t i = 0; i < multiboot->mods_count; i++) {
const char *base = reinterpret_cast<const char*>(mods[i].start);
const char *top = reinterpret_cast<const char*>(mods[i].end);
const char *base = reinterpret_cast<const char*>(uintptr_t(mods[i].start));
const char *top = reinterpret_cast<const char*>(uintptr_t(mods[i].end));
size_t length = top - base;
MemoryStream ms(base, length);
loadStream(&ms, 1);
......
......@@ -153,17 +153,16 @@ static bool readelf_dylink_handle_dynamic_jmprel(Process *process,
if (sym.name) {
char *name = process->readString(strtab + sym.name);
addr = process->linkLibrary(name);
delete name;
if (addr == 0) {
printf("Cannot link symbol: %s\n", name);
delete name;
return 0;
}
delete name;
} else {
return 0;
}
} else {
printf("SYM=%016lx n=%x i=%x s=%x sz=%lx\n",
sym.value, sym.name, sym.info, sym.shndx, sym.size);
return 0;
}
addr += rel.add;
......@@ -210,7 +209,7 @@ static bool readelf_dylink_handle_dynamic_symtab(Process *process,
uintptr_t ptr = readelf_find_load_addr(process, start, sym.value);
if (ptr == 0) continue;
char *name = process->readString(strtab + sym.name);
if (name && strlen(name) > 0) process->addSymbol(name, ptr);
if (name && name[0] != 0) process->addSymbol(name, ptr);
delete name;
}
return 1;
......@@ -356,7 +355,7 @@ size_t readelf(Process *process, Stream *stream) {
off += prog->filesz - offset_load;
process->writeData(vaddr + offset_load, buf,
prog->filesz - offset_load);
delete buf; buf = 0;
delete[] buf; buf = 0;
prog->vaddr = vaddr;
}
break;
......
......@@ -72,7 +72,7 @@ enum ELF64_PROG_TYPE: uint32_t {
PT_LOOS = 0x60000000,
PT_HIOS = 0x6FFFFFFF,
PT_LOPROC = 0x70000000,
PT_HIPROC = 0x6FFFFFFF
PT_HIPROC = 0x7FFFFFFF
};
enum ELF64_PROG_FLAGS: uint32_t {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment