Skip to content

Commit

Permalink
Merge pull request #548 from ddiss/fix_some_minor_compiler_warnings
Browse files Browse the repository at this point in the history
Fix some minor compiler warnings
  • Loading branch information
tavip authored Nov 14, 2024
2 parents 699f87c + b133968 commit 63bed8b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
1 change: 0 additions & 1 deletion arch/lkl/kernel/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ void __generic_xchg_called_with_bad_pointer(void)
unsigned long wrong_size_cmpxchg(volatile void *ptr)
{
panic("%s shouldn't be executed\n", __func__);
return 0;
}

#ifdef CONFIG_PROC_FS
Expand Down
19 changes: 10 additions & 9 deletions arch/lkl/mm/bootmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
#include <linux/swap.h>

unsigned long memory_start, memory_end;
static unsigned long _memory_start, mem_size;
static void *_memory_start;
static unsigned long mem_size;

void *empty_zero_page;

Expand All @@ -16,12 +17,12 @@ void __init bootmem_init(unsigned long mem_sz)

if (lkl_ops->page_alloc) {
mem_size = PAGE_ALIGN(mem_size);
_memory_start = (unsigned long)lkl_ops->page_alloc(mem_size);
_memory_start = lkl_ops->page_alloc(mem_size);
} else {
_memory_start = (unsigned long)lkl_ops->mem_alloc(mem_size);
_memory_start = lkl_ops->mem_alloc(mem_size);
}

memory_start = _memory_start;
memory_start = (unsigned long)_memory_start;
BUG_ON(!memory_start);
memory_end = memory_start + mem_size;

Expand All @@ -36,12 +37,12 @@ void __init bootmem_init(unsigned long mem_sz)
* Give all the memory to the bootmap allocator, tell it to put the
* boot mem_map at the start of memory.
*/
max_low_pfn = virt_to_pfn(memory_end);
min_low_pfn = virt_to_pfn(memory_start);
max_low_pfn = virt_to_pfn((void *)memory_end);
min_low_pfn = virt_to_pfn((void *)memory_start);
memblock_add(memory_start, mem_size);

empty_zero_page = memblock_alloc(PAGE_SIZE, PAGE_SIZE);
memset((void *)empty_zero_page, 0, PAGE_SIZE);
memset(empty_zero_page, 0, PAGE_SIZE);

zones_max_pfn[ZONE_NORMAL] = max_low_pfn;
free_area_init(zones_max_pfn);
Expand All @@ -66,7 +67,7 @@ void free_initmem(void)
void free_mem(void)
{
if (lkl_ops->page_free)
lkl_ops->page_free((void *)_memory_start, mem_size);
lkl_ops->page_free(_memory_start, mem_size);
else
lkl_ops->mem_free((void *)_memory_start);
lkl_ops->mem_free(_memory_start);
}
12 changes: 8 additions & 4 deletions tools/lkl/lib/vfio_pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ static struct lkl_pci_dev *vfio_pci_add(const char *name, void *kernel_ram,
unsigned long ram_size)
{
struct lkl_pci_dev *dev;
char path[128];
char path[128], link[128], *l;
int segn, busn, devn, funcn;
int i;
int container_fd = 0, group_fd = 0;
Expand Down Expand Up @@ -77,12 +77,16 @@ static struct lkl_pci_dev *vfio_pci_add(const char *name, void *kernel_ram,
"/sys/bus/pci/devices/%04x:%02x:%02x.%01x/iommu_group", segn,
busn, devn, funcn);

i = readlink(path, path, sizeof(path));
i = readlink(path, link, sizeof(link) - 1);
if (i < 0)
goto error;

path[i] = '\0';
snprintf(path, sizeof(path), "/dev/vfio%s", strrchr(path, '/'));
link[i] = '\0';
l = strrchr(link, '/');
if (l == NULL)
goto error;

snprintf(path, sizeof(path), "/dev/vfio%s", l);

group_fd = open(path, O_RDWR);
if (group_fd < 0)
Expand Down

0 comments on commit 63bed8b

Please sign in to comment.