From c72ec469ce850f8e2ca65f1bf08c0c35d8a6001b Mon Sep 17 00:00:00 2001 From: Alex Campbell Date: Mon, 1 Mar 2021 09:34:02 -0500 Subject: [PATCH] Fix #70, fix comment stlye --- elf2cfetbl.c | 34 +++++++++++++++++----------------- elf2cfetbl_version.h | 21 +++++++++++---------- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/elf2cfetbl.c b/elf2cfetbl.c index 1566622..182f7c4 100644 --- a/elf2cfetbl.c +++ b/elf2cfetbl.c @@ -941,14 +941,14 @@ int32 ProcessCmdLineOptions(int ArgumentCount, char *Arguments[]) { if ((Arguments[i][0] == '-') && (Arguments[i][1] == 't')) { - // Extract the Table Name Override + /* Extract the Table Name Override */ strncpy(TableName, &Arguments[i][2], sizeof(TableName) - 1); TableName[sizeof(TableName) - 1] = 0; TableNameOverride = true; } else if ((Arguments[i][0] == '-') && (Arguments[i][1] == 'd')) { - // Extract the Description Override + /* Extract the Description Override */ strncpy(Description, &Arguments[i][2], sizeof(Description) - 1); Description[sizeof(Description) - 1] = 0; DescriptionOverride = true; @@ -1235,13 +1235,13 @@ int32 ProcessCmdLineOptions(int ArgumentCount, char *Arguments[]) { strncpy(SrcFilename, Arguments[i], PATH_MAX - 1); SrcFilename[PATH_MAX - 1] = '\0'; - InputFileSpecified = true; + InputFileSpecified = true; } else if (!OutputFileSpecified) { strncpy(DstFilename, Arguments[i], PATH_MAX - 1); DstFilename[PATH_MAX - 1] = '\0'; - OutputFileSpecified = true; + OutputFileSpecified = true; } else { @@ -1281,7 +1281,7 @@ int32 ProcessCmdLineOptions(int ArgumentCount, char *Arguments[]) void OutputVersionInfo(void) { - printf("\n%s\n", ELF2CFETBL_VERSION_STRING); + printf("\n%s\n", ELF2CFETBL_VERSION_STRING); } /** @@ -1290,7 +1290,7 @@ void OutputVersionInfo(void) void OutputHelpInfo(void) { - printf("\nElf Object File to cFE Table Image File Conversion Tool (elf2cfetbl)\n\n"); + printf("\nElf Object File to cFE Table Image File Conversion Tool (elf2cfetbl)\n\n"); printf("elf2cfetbl [-tTblName] [-d\"Description\"] [-h] [-v] [-V] [-s#] [-p#] [-n] \n"); printf(" [-T] [-eYYYY:MM:DD:hh:mm:ss] [-fYYYY:MM:DD:hh:mm:ss] SrcFilename [DestDirectory]\n"); printf(" where:\n"); @@ -1404,10 +1404,10 @@ int32 GetDstFilename(void) int32 OpenSrcFile(void) { - int RtnCode; - char TimeBuff[50]; + int RtnCode; + char TimeBuff[50]; - // Check to see if input file can be found and opened + /* Check to see if input file can be found and opened */ SrcFileDesc = fopen(SrcFilename, "r"); if (SrcFileDesc == NULL) @@ -1443,7 +1443,7 @@ int32 OpenDstFile(void) { struct stat dststat; - // Check to see if output file can be opened and written + /* Check to see if output file can be opened and written */ DstFileDesc = fopen(DstFilename, "w"); if (DstFileDesc == NULL) @@ -1489,7 +1489,7 @@ int32 GetElfHeader(void) return FAILED; } - // Begin by reading e_ident characters + /* Begin by reading e_ident characters */ NumHdrsRead = fread(&ElfHeader, EI_NIDENT, 1, SrcFileDesc); if (NumHdrsRead != 1) @@ -1614,7 +1614,7 @@ int32 GetElfHeader(void) if (Verbose) printf(" e_ident[EI_VERSION] = %d\n", get_e_ident(&ElfHeader, EI_VERSION)); - // Now that e_ident is processed (with word size), read rest of the header + /* Now that e_ident is processed (with word size), read rest of the header */ if (TargetWordsizeIs32Bit) { NumHdrsRead = fread(&(ElfHeader.Ehdr32.e_type), sizeof(Elf32_Ehdr) - EI_NIDENT, 1, SrcFileDesc); @@ -1787,8 +1787,8 @@ int32 GetSectionHeader(int32 SectionIndex, union Elf_Shdr *SectionHeader) * Not all compilers generate a separate strtab for section header names; some put everything * into one string table. */ - if (strcmp(SectionNamePtrs[SectionIndex],".strtab") == 0 || - (StringTableDataOffset == 0 && SectionIndex != get_e_shstrndx(&ElfHeader))) + if (strcmp(SectionNamePtrs[SectionIndex], ".strtab") == 0 || + (StringTableDataOffset == 0 && SectionIndex != get_e_shstrndx(&ElfHeader))) { StringTableDataOffset = get_sh_offset(SectionHeader); } @@ -2266,7 +2266,7 @@ int32 GetTblDefInfo(void) } else { - // fseek expects a long int, sh_offset and st_value are uint64 for elf64 + /* 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]); SeekOffset = (uint32_t)(calculated_offset); @@ -2279,8 +2279,8 @@ int32 GetTblDefInfo(void) NumDefsRead = fread(&TblFileDef, sizeof(CFE_TBL_FileDef_t), 1, SrcFileDesc); /* ensuring all are strings are null-terminated */ - TblFileDef.ObjectName[sizeof(TblFileDef.ObjectName) - 1] = '\0'; - TblFileDef.TableName[sizeof(TblFileDef.TableName) - 1] = '\0'; + TblFileDef.ObjectName[sizeof(TblFileDef.ObjectName) - 1] = '\0'; + TblFileDef.TableName[sizeof(TblFileDef.TableName) - 1] = '\0'; TblFileDef.Description[sizeof(TblFileDef.Description) - 1] = '\0'; TblFileDef.TgtFilename[sizeof(TblFileDef.TgtFilename) - 1] = '\0'; diff --git a/elf2cfetbl_version.h b/elf2cfetbl_version.h index 01e235e..c084b03 100644 --- a/elf2cfetbl_version.h +++ b/elf2cfetbl_version.h @@ -18,21 +18,21 @@ ** limitations under the License. */ - /*! @file elf2cfetbl_version.h * @brief Purpose: * @details Provide version identifiers for the ELF to cFE Table Converter. @n * See @ref cfsversions for version and build number and description - * + * */ #ifndef ELF2CFETBL_VERSION_H #define ELF2CFETBL_VERSION_H /* - * Development Build Macro Definitions + * Development Build Macro Definitions */ #define ELF2CFETBL_BUILD_NUMBER 9 /*!< @brief Number of commits since baseline */ -#define ELF2CFETBL_BUILD_BASELINE "v3.2.0-rc1" /*!< @brief Development Build: git tag that is the base for the current */ +#define ELF2CFETBL_BUILD_BASELINE \ + "v3.2.0-rc1" /*!< @brief Development Build: git tag that is the base for the current */ /* * Version Macro Definitions @@ -44,20 +44,21 @@ /* * Tools to construct version string - */ + */ #define ELF2CFETBL_STR_HELPER(x) #x /*!< @brief Helper function to concatenate strings from integer macros */ -#define ELF2CFETBL_STR(x) ELF2CFETBL_STR_HELPER(x) /*!< @brief Helper function to concatenate strings from integer macros */ +#define ELF2CFETBL_STR(x) \ + ELF2CFETBL_STR_HELPER(x) /*!< @brief Helper function to concatenate strings from integer macros */ -/*! @brief Development Build Version Number. +/*! @brief Development Build Version Number. * @details Baseline git tag + Number of commits since baseline. @n * See @ref cfsversions for format differences between development and release versions. */ #define ELF2CFETBL_VERSION ELF2CFETBL_BUILD_BASELINE ELF2CFETBL_STR(ELF2CFETBL_BUILD_NUMBER) /*! @brief Development Build Version String. - * @details Reports the current development build's baseline, number, and name. Also includes a note about the latest official version. @n - * See @ref cfsversions for format differences between development and release versions. -*/ + * @details Reports the current development build's baseline, number, and name. Also includes a note about the latest + * official version. @n See @ref cfsversions for format differences between development and release versions. + */ #define ELF2CFETBL_VERSION_STRING \ " elf2cfetbl Development Build\n" \ " " ELF2CFETBL_VERSION " (Codename: Bootes)\n" /* Codename for current development */ \