Skip to content

Commit

Permalink
Code quality: Fixing code quality issues reported by lgtm
Browse files Browse the repository at this point in the history
Signed-off-by: Deepak Gupta <[email protected]>
  • Loading branch information
dkgupta-amzn authored and wipawel committed Aug 25, 2020
1 parent d259b22 commit 11d43b4
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 20 deletions.
10 changes: 5 additions & 5 deletions arch/x86/pagetables.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static inline void dump_page_table(void *table, int level) {

dump_pte_flags(flags, sizeof(flags), pt[i]);
paddr_t paddr = mfn_to_paddr(pt[i].mfn);
printk("[%p] %*s%d[%03u] paddr: 0x%016lx flags: %s\n", virt_to_paddr(pt),
printk("[%p] %*s%d[%03u] paddr: 0x%016lx flags: %s\n", _ptr(virt_to_paddr(pt)),
(4 - level) * 2, "L", level, i, paddr, flags);

if (level == 2 && ((pde_t *) pt)[i].PS)
Expand Down Expand Up @@ -109,11 +109,11 @@ static void *init_map_mfn(mfn_t mfn) {
return _tmp;
}

static mfn_t get_cr3_mfn(cr3_t *cr3) {
if (mfn_invalid(cr3->mfn))
cr3->mfn = get_free_frame();
static mfn_t get_cr3_mfn(cr3_t *cr3_entry) {
if (mfn_invalid(cr3_entry->mfn))
cr3_entry->mfn = get_free_frame();

return cr3->mfn;
return cr3_entry->mfn;
}

static mfn_t get_pgentry_mfn(mfn_t tab_mfn, pt_index_t index, unsigned long flags) {
Expand Down
8 changes: 4 additions & 4 deletions arch/x86/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,10 @@ static void dump_control_regs(const struct cpu_regs *regs) {

static void dump_segment_regs(const struct cpu_regs *regs) {
printk("CURRENT:\n"
"CS=0x%04x DS=0x%04x SS=0x%04x\n"
"ES=0x%04x FS=0x%04x GS=0x%04x\n"
"CS=0x%04lx DS=0x%04lx SS=0x%04lx\n"
"ES=0x%04lx FS=0x%04lx GS=0x%04lx\n"
"EXCEPTION:\n"
"CS=0x%04x SS=0x%04x\n\n",
"CS=0x%04lx SS=0x%04lx\n\n",
read_cs(), read_ds(), read_ss(), read_es(), read_fs(), read_gs(), regs->cs,
regs->ss);
}
Expand All @@ -192,7 +192,7 @@ static void dump_stack(const struct cpu_regs *regs, unsigned words) {
printk("STACK[0x%016p]:", sp);
for (unsigned i = 0; i == 0 || (_ul(&sp[i]) % PAGE_SIZE_2M); i++) {
if ((i % words) == 0)
printk("\n0x%04x: ", i * (sizeof(unsigned long)));
printk("\n0x%04lx: ", i * (sizeof(unsigned long)));
printk("%016lx ", sp[i]);
}
printk("\n\n");
Expand Down
14 changes: 8 additions & 6 deletions common/acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ static inline void *find_rsdp(void *from, void *to) {
rsdp_rev1_t *rsdp = addr;

if (validate_rsdp(rsdp)) {
printk("ACPI: RSDP [%p] v%02x %.*s\n", virt_to_paddr(rsdp), rsdp->rev,
sizeof(rsdp->oem_id), rsdp->oem_id);
printk("ACPI: RSDP [%p] v%02x %.*s\n", _ptr(virt_to_paddr(rsdp)), rsdp->rev,
_int(sizeof(rsdp->oem_id)), rsdp->oem_id);
return rsdp;
}
}
Expand Down Expand Up @@ -147,17 +147,19 @@ static void acpi_dump_tables(void) {
acpi_table_hdr_t *hdr = &tab->header;

printk("ACPI: %.*s [%p] %04x (v%04x %.*s %04x %.*s %08x)\n",
sizeof(hdr->signature), &hdr->signature, tab, hdr->length, hdr->rev,
sizeof(hdr->oem_id), hdr->oem_id, hdr->oem_rev,
sizeof(hdr->asl_compiler_id), hdr->asl_compiler_id, hdr->asl_compiler_rev);
_int(sizeof(hdr->signature)), (char *) &hdr->signature, tab, hdr->length,
hdr->rev, _int(sizeof(hdr->oem_id)), hdr->oem_id, hdr->oem_rev,
_int(sizeof(hdr->asl_compiler_id)), hdr->asl_compiler_id,
hdr->asl_compiler_rev);
}
}

static unsigned process_madt_entries(void) {
acpi_madt_t *madt = (acpi_madt_t *) acpi_find_table(MADT_SIGNATURE);
acpi_madt_entry_t *entry;

printk("ACPI: [MADT] LAPIC Addr: %p, Flags: %08x\n", madt->lapic_addr, madt->flags);
printk("ACPI: [MADT] LAPIC Addr: %p, Flags: %08x\n", _ptr(madt->lapic_addr),
madt->flags);

for (void *addr = madt->entry; addr < (_ptr(madt) + madt->header.length);
addr += entry->len) {
Expand Down
1 change: 1 addition & 0 deletions include/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#ifndef __ASSEMBLY__
#define _ptr(val) ((void *) (unsigned long) (val))
#define _ul(val) ((unsigned long) (val))
#define _int(val) ((int) (val))
#endif

#define __aligned(x) __attribute__((__aligned__(x)))
Expand Down
3 changes: 2 additions & 1 deletion mm/pmm.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ void display_memory_map(void) {

for_each_memory_range (r) {
printk("%11s: VA: [0x%016lx - 0x%016lx] PA: [0x%08lx - 0x%08lx]\n", r->name,
r->start, r->end, r->start - r->base, r->end - r->base);
_ul(r->start), _ul(r->end), _ul(r->start - r->base),
_ul(r->end - r->base));
}
}

Expand Down
2 changes: 1 addition & 1 deletion mm/slab.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void *ktf_alloc(unsigned int size) {
*/
order_index -= 4;

printk("Alloc size %lu, powerof 2 size %lu, order %lu\n", size, size_power2,
printk("Alloc size %u, powerof 2 size %u, order %u\n", size, size_power2,
order_index);
/* Go through list of meta_slab_t and try to allocate a free slab */
list_for_each_entry (slab, &meta_slab_list[order_index], list) {
Expand Down
6 changes: 3 additions & 3 deletions smp/mptables.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ static void dump_mpf(mpf_t *ptr) {

static void dump_mpc_hdr(mpc_hdr_t *ptr) {
printk("\nMP Configuration Table Header at %p:\n", ptr);
printk(" Signature: %.4s\n", &ptr->signature);
printk(" Signature: %.4s\n", (char *) &ptr->signature);
printk(" Length: 0x%02x\n", ptr->length);
printk(" Spec revision: 0x%02x\n", ptr->spec_rev);
printk(" Checksum: 0x%02x\n", ptr->checksum);
Expand All @@ -138,7 +138,7 @@ static void dump_mpc_hdr(mpc_hdr_t *ptr) {
printk(" OEM Table Ptr: %p\n", _ptr(ptr->oem_tlb_ptr));
printk(" OEM Table Size: %x\n", ptr->oem_tlb_size);
printk(" Entry count: %x\n", ptr->entry_count);
printk(" LAPIC base address: %p\n", ptr->lapic_base);
printk(" LAPIC base address: %p\n", _ptr(ptr->lapic_base));
printk(" Extended Table Length: %x\n", ptr->ext_length);
printk(" Extended Table Checksum: %x\n", ptr->ext_checksum);
}
Expand All @@ -156,7 +156,7 @@ static inline void dump_mpc_bus_entry(const mpc_bus_entry_t *e) {

static inline void dump_mpc_ioapic_entry(const mpc_ioapic_entry_t *e) {
printk(" IOAPIC: ID=%x, Version=%x, Enabled=%x, Address: %p\n", e->id, e->version,
e->en, e->base_addr);
e->en, _ptr(e->base_addr));
}

static const char *mpc_interrupt_type_names[] = {
Expand Down

0 comments on commit 11d43b4

Please sign in to comment.