HV:  MISRA clean in reloc.c
The patch is to fix MISRA violation in reloc.c by:
- remove multi-returns in relocate();
- remove non useful checking in relocate();
- add suffix U to macro definition
Acked-by: Anthony Xu
#include <ld_sym.h>
#ifdef CONFIG_RELOC
-#define DT_NULL 0 /* end of .dynamic section */
-#define DT_RELA 7 /* relocation table */
-#define DT_RELASZ 8 /* size of reloc table */
-#define DT_RELAENT 9 /* size of one entry */
+#define DT_NULL 0U /* end of .dynamic section */
+#define DT_RELA 7U /* relocation table */
+#define DT_RELASZ 8U /* size of reloc table */
+#define DT_RELAENT 9U /* size of one entry */
#define R_X86_64_RELATIVE 8UL
@@ -67,9 +67,7 @@ void relocate(void)
/* get the delta that needs to be patched */
delta = get_hv_image_delta();
- if (delta == 0U) {
- return;
- }
+ if (delta != 0U) {
/* Look for the descriptoin of relocation sections */
for (dyn = (struct Elf64_Dyn *)_DYNAMIC; dyn->d_tag != DT_NULL; dyn++) {
@@ -83,14 +81,12 @@ void relocate(void)
case DT_RELAENT:
size = dyn->d_ptr;
break;
+ default:
+ /* if no RELA/RELASZ found, both start and end will be initialized to NULL, and later while loop won't be executed */
+ break;
}
}
- /* Sanity check */
- if ((start == NULL) || (size == 0U)) {
- return;
- }
-
/*
* Need to subtract the relocation delta to get the correct
* absolute addresses
@@ -125,5 +121,6 @@ void relocate(void)
}
start = (struct Elf64_Rel *)((char *)start + size);
}
+ }
#endif
}
