Skip to content

Commit

Permalink
Fix #126, Move variables declared mid-function to the top
Browse files Browse the repository at this point in the history
  • Loading branch information
thnkslprpt committed Mar 14, 2023
1 parent 46b29f8 commit 8e1df14
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions elf2cfetbl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2256,9 +2256,10 @@ int32 GetStringFromMap(char *Result, ElfStrMap *Map, int32 Key)

int32 GetTblDefInfo(void)
{
int32 Status = SUCCESS;
uint32 SeekOffset = 0;
int32 NumDefsRead = 0;
int32 Status = SUCCESS;
uint32 SeekOffset = 0;
int32 NumDefsRead = 0;
uint64_t calculated_offset;

/* Read the data to be used to format the CFE File and Table Headers */
if ((get_st_size(SymbolPtrs[TblDefSymbolIndex]) != sizeof(CFE_TBL_FileDef_t)) &&
Expand All @@ -2271,8 +2272,8 @@ int32 GetTblDefInfo(void)
else
{
/* fseek expects a long int, sh_offset and st_value are uint64 for elf64 */
uint64_t calculated_offset = get_sh_offset(SectionHeaderPtrs[get_st_shndx(SymbolPtrs[TblDefSymbolIndex])]) +
get_st_value(SymbolPtrs[TblDefSymbolIndex]);
calculated_offset = get_sh_offset(SectionHeaderPtrs[get_st_shndx(SymbolPtrs[TblDefSymbolIndex])]) +
get_st_value(SymbolPtrs[TblDefSymbolIndex]);
SeekOffset = (uint32_t)(calculated_offset);
if (SeekOffset != calculated_offset)
{
Expand Down Expand Up @@ -2327,11 +2328,12 @@ int32 GetTblDefInfo(void)

int32 LocateAndReadUserObject(void)
{
int32 Status = SUCCESS;
int32 i = 0;
int32 j = 0;
uint32 SeekOffset = 0;
uint8 AByte;
int32 Status = SUCCESS;
int32 i = 0;
int32 j = 0;
uint32 SeekOffset = 0;
uint8 AByte;
uint64_t calculated_offset;

/* Search the symbol table for the user defined object */
if (Verbose)
Expand Down Expand Up @@ -2424,9 +2426,8 @@ int32 LocateAndReadUserObject(void)
else
{
/* Locate data associated with symbol */
uint64_t calculated_offset =
get_sh_offset(SectionHeaderPtrs[get_st_shndx(SymbolPtrs[UserObjSymbolIndex])]) +
get_st_value(SymbolPtrs[UserObjSymbolIndex]);
calculated_offset = get_sh_offset(SectionHeaderPtrs[get_st_shndx(SymbolPtrs[UserObjSymbolIndex])]) +
get_st_value(SymbolPtrs[UserObjSymbolIndex]);
SeekOffset = (uint32_t)(calculated_offset);
if (SeekOffset != calculated_offset)
{
Expand Down

0 comments on commit 8e1df14

Please sign in to comment.