Skip to content

Commit

Permalink
Merge pull request #127 from thnkslprpt:fix-126-variables-declared-mi…
Browse files Browse the repository at this point in the history
…d-function

Fix #126, Move variables declared mid-function to the top
  • Loading branch information
dzbaker committed Jul 2, 2024
2 parents 1ca5d27 + 8e1df14 commit b20d615
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 @@ -2273,9 +2273,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 @@ -2288,8 +2289,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 @@ -2344,11 +2345,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 @@ -2441,9 +2443,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 b20d615

Please sign in to comment.