@@ -200,7 +200,7 @@ int load_ebpf_mem_progs() {
200200 mem_ebpf_skel = mem_ebpf__open ();
201201 if (!mem_ebpf_skel ) {
202202 perror ("Failed to open BPF skeleton" );
203- return errno ;
203+ return - errno ;
204204 }
205205
206206 /* ARM64 phys to virt translation requires two values, one of the two (CONFIG_ARM64_VA_BITS)
@@ -219,7 +219,7 @@ int load_ebpf_mem_progs() {
219219 /* Load the BPF objectes */
220220 if (mem_ebpf__load (mem_ebpf_skel )) {
221221 perror ("Failed to load BPF object" );
222- return errno ;
222+ return - errno ;
223223 }
224224
225225 /* Attach the uprobe to the 'read_kernel_memory' function in the current executable */
@@ -288,7 +288,6 @@ void cleanup_mem_ebpf() {
288288 * Performs architecture-specific translation using kernel direct mapping.
289289 * Currently supports x86_64 and ARM64 only.
290290 */
291-
292291uintptr_t phys_to_virt (const uintptr_t phy_addr ) {
293292 #ifdef __TARGET_ARCH_x86
294293 return phy_addr + v2p_offset ;
@@ -388,12 +387,11 @@ int __attribute__((noinline, optnone)) read_kernel_memory(const uintptr_t addr,
388387 * Scans the line for the symbol name and extracts its address using sscanf.
389388 * Returns 1 on success, 0 on not looked for element or a negative error code from read_kernel_memory().
390389 */
391-
392390static int inline parse_kallsyms_line (const char * restrict line , const char * restrict symbol , uintptr_t * restrict current_symb_addr ) {
393391 char current_symb_name [256 ];
394392
395393 /* Read the address and check if the it is the symbol that we look for */
396- if ((sscanf (line , "%lx %*c %255s\n" ,current_symb_addr , current_symb_name ) != 2 ) || strncmp (current_symb_name , symbol , strlen (symbol )))
394+ if ((sscanf (line , "%lx %*c %255s\n" , current_symb_addr , current_symb_name ) != 2 ) || strncmp (current_symb_name , symbol , strlen (symbol )))
397395 return 0 ;
398396
399397 /* Check that address is not 0 */
@@ -405,10 +403,10 @@ static int inline parse_kallsyms_line(const char *restrict line, const char *res
405403 *
406404 * Opens /proc/kallsyms, searches for the appropriate symbol (e.g., "page_offset_base" or
407405 * "memstart_addr" and "iomem_resource") based on architecture, and retrieves the physical-to-virtual address
408- * translation offset and the pointer to the tree of physical memory regions. Returns 0 on success, or an error code on failure.
406+ * translation offset and the pointer to the tree of physical memory regions.
407+ * Returns 0 on success, or an error code on failure.
409408 */
410- static int parse_kallsyms ()
411- {
409+ static int parse_kallsyms () {
412410 FILE * fp ;
413411 char line [256 ];
414412 __u8 * data = NULL ;
@@ -488,11 +486,10 @@ static int parse_kallsyms()
488486 *
489487 * Opens /proc/iomem, searches for "System RAM" regions, and populates the provided
490488 * ram_regions struct with the start and end addresses of each region. The function
491- * reallocates memory as needed to accommodate additional regions. Returns 0 on success,
492- * or an error code on failure.
489+ * reallocates memory as needed to accommodate additional regions.
490+ * Returns 0 on success, or an error code on failure.
493491 */
494- static int get_iomem_regions_user (struct ram_regions * restrict ram_regions )
495- {
492+ static int get_iomem_regions_user (struct ram_regions * restrict ram_regions ) {
496493 FILE * fp ;
497494 char line [256 ];
498495 int slot_availables ;
@@ -565,11 +562,10 @@ static int get_iomem_regions_user(struct ram_regions *restrict ram_regions)
565562 *
566563 * Read struct resources from kernel, and populates the provided
567564 * ram_regions struct with the start and end addresses of each region. The function
568- * reallocates memory as needed to accommodate additional regions. Returns 0 on success,
569- * or an error code on failure.
565+ * reallocates memory as needed to accommodate additional regions.
566+ * Returns 0 on success, or an error code on failure.
570567 */
571- static int get_iomem_regions_kernel (struct ram_regions * restrict ram_regions )
572- {
568+ static int get_iomem_regions_kernel (struct ram_regions * restrict ram_regions ) {
573569 int slot_availables ;
574570 __u8 * data = NULL ;
575571 struct resource * res , * next_res ;
@@ -590,7 +586,7 @@ static int get_iomem_regions_kernel(struct ram_regions *restrict ram_regions)
590586 * Is it possible to have "System RAM" regions inside non System RAM regions? I don't think so.
591587 */
592588
593- /* Obrain the address child of the root struct */
589+ /* Obtain the address child of the root struct */
594590 if ((err = read_kernel_memory (iomem_resource , sizeof (struct resource ), & data ))) {
595591 fprintf (stderr , "Error reading root struct resource" );
596592 return err ;
0 commit comments