summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorEvan Lojewski <github@meklort.com>2021-02-06 16:29:58 -0700
committerGitHub <noreply@github.com>2021-02-06 16:29:58 -0700
commita1b8330b2506ffa6a30bfc4153149b9184ea76cf (patch)
treef503723aebe715a0acd1eba2d6ba066f3fe53754 /utils
parentaf7847795c9096067c976901a6149350534ae42c (diff)
downloadbcm5719-ortega-a1b8330b2506ffa6a30bfc4153149b9184ea76cf.tar.gz
bcm5719-ortega-a1b8330b2506ffa6a30bfc4153149b9184ea76cf.zip
build: Fix a number of compiler issues when building utils with gcc. (#208)
Diffstat (limited to 'utils')
-rw-r--r--utils/ape2elf/main.cpp4
-rwxr-xr-xutils/bcmflash/CMakeLists.txt5
-rw-r--r--utils/bcmflash/create_header.cpp (renamed from utils/bcmflash/create_header.c)0
-rw-r--r--utils/bcmflash/ethtool.c6
-rwxr-xr-xutils/bcmflash/ethtool.h10
-rw-r--r--utils/bcmflash/main.cpp12
-rw-r--r--utils/bcmregtool/main.cpp4
-rw-r--r--utils/elf2ape/main.cpp7
8 files changed, 27 insertions, 21 deletions
diff --git a/utils/ape2elf/main.cpp b/utils/ape2elf/main.cpp
index 7daa80a..355ca37 100644
--- a/utils/ape2elf/main.cpp
+++ b/utils/ape2elf/main.cpp
@@ -95,7 +95,7 @@ int main(int argc, char const *argv[])
if (ape.words[0] == be32toh(APE_HEADER_MAGIC))
{
// The file is swapped... fix it.
- for (int i = 0; i < sizeof(ape) / sizeof(ape.words[0]); i++)
+ for (size_t i = 0; i < sizeof(ape) / sizeof(ape.words[0]); i++)
{
ape.words[i] = be32toh(ape.words[i]);
}
@@ -151,7 +151,7 @@ int main(int argc, char const *argv[])
printf("UNK0: 0x%08X\n", ape.header.unk0);
char name[sizeof(ape.header.name) + 1] = { 0 };
- strncpy(name, (char *)ape.header.name, sizeof(ape.header.name));
+ strncpy(name, (char *)ape.header.name, sizeof(name) - 1);
printf("Name: %s\n", name);
printf("Version: 0x%08X (%d.%d.%d)\n", ape.header.version, version_major, version_minor, version_patch);
printf("Start: 0x%08X\n", ape.header.entrypoint);
diff --git a/utils/bcmflash/CMakeLists.txt b/utils/bcmflash/CMakeLists.txt
index fd41194..fb6e5b7 100755
--- a/utils/bcmflash/CMakeLists.txt
+++ b/utils/bcmflash/CMakeLists.txt
@@ -9,7 +9,7 @@ set(SOURCES
bcmflash.h
# Support files for initializing the firmware header
- create_header.c create_header.h
+ create_header.cpp create_header.h
nvm_talos2.c
nvm_blackbird.c
nvm_kh08p.c
@@ -21,8 +21,9 @@ IF(CONFIG_HAVE_LINUX_ETHTOOL_H)
)
ENDIF()
-simulator_add_executable(${PROJECT_NAME} ${SOURCES})
+add_executable(${PROJECT_NAME} ${SOURCES})
target_link_libraries(${PROJECT_NAME} PRIVATE NVRam VPD simulator OptParse)
+target_compile_options(${PROJECT_NAME} PRIVATE -DCXX_SIMULATOR)
format_target_sources(${PROJECT_NAME})
diff --git a/utils/bcmflash/create_header.c b/utils/bcmflash/create_header.cpp
index 133c351..133c351 100644
--- a/utils/bcmflash/create_header.c
+++ b/utils/bcmflash/create_header.cpp
diff --git a/utils/bcmflash/ethtool.c b/utils/bcmflash/ethtool.c
index 76d2ed3..2aaad36 100644
--- a/utils/bcmflash/ethtool.c
+++ b/utils/bcmflash/ethtool.c
@@ -71,7 +71,7 @@ static int do_ioctl(struct cmd_context *ctx, void *cmd)
size_t bcmflash_ethtool_size(const char *name)
{
- cmd_context ctx = { 0 };
+ struct cmd_context ctx = { 0 };
strcpy(ctx.ifr.ifr_name, name);
@@ -97,7 +97,7 @@ bool bcmflash_ethtool_read(const char *name, void *buffer, size_t len)
uint32_t eeprom_size = bcmflash_ethtool_size(name);
- cmd_context ctx = { 0 };
+ struct cmd_context ctx = { 0 };
strcpy(ctx.ifr.ifr_name, name);
@@ -137,7 +137,7 @@ bool bcmflash_ethtool_write(const char *name, void *buffer, size_t len)
uint32_t eeprom_size = bcmflash_ethtool_size(name);
- cmd_context ctx = { 0 };
+ struct cmd_context ctx = { 0 };
strcpy(ctx.ifr.ifr_name, name);
diff --git a/utils/bcmflash/ethtool.h b/utils/bcmflash/ethtool.h
index d42906b..08655f0 100755
--- a/utils/bcmflash/ethtool.h
+++ b/utils/bcmflash/ethtool.h
@@ -42,12 +42,12 @@
/// @endcond
////////////////////////////////////////////////////////////////////////////////
-#ifndef IFACE_H
-#define IFACE_H
+#ifndef ETHTOOL_H
+#define ETHTOOL_H
#include <stdint.h>
-#ifdef __cplusplus__
+#ifdef __cplusplus
extern "C" {
#endif
@@ -55,8 +55,8 @@ bool bcmflash_ethtool_read(const char *name, void *buffer, size_t len);
bool bcmflash_ethtool_write(const char *name, void *buffer, size_t len);
size_t bcmflash_ethtool_size(const char *name);
-#ifdef __cplusplus__
+#ifdef __cplusplus
}
#endif
-#endif /* IFACE_H */
+#endif /* ETHTOOL_H */
diff --git a/utils/bcmflash/main.cpp b/utils/bcmflash/main.cpp
index 1a48e9b..6e32edf 100644
--- a/utils/bcmflash/main.cpp
+++ b/utils/bcmflash/main.cpp
@@ -337,7 +337,7 @@ void dump_info(NVRAMInfo_t *info, NVRAMInfo2_t *info2)
printf("Power Budget2: 0x%04X%04X\n", pb_raw[5], pb_raw[4]);
printf("Power Budget3: 0x%04X%04X\n", pb_raw[7], pb_raw[6]);
- for (int i = 0; i < ARRAY_ELEMENTS(pb_raw); i++)
+ for (size_t i = 0; i < ARRAY_ELEMENTS(pb_raw); i++)
{
uint32_t raw = pb_raw[i];
RegDEVICEPciPowerBudget0_t pb0;
@@ -351,7 +351,7 @@ void dump_info(NVRAMInfo_t *info, NVRAMInfo2_t *info2)
pb0.bits.PowerRail = (raw & 0xE000) >> 13;
}
- printf("Translated Power Budget[%d]: 0x%08X\n", i, (uint32_t)pb0.r32);
+ printf("Translated Power Budget[%zu]: 0x%08X\n", i, (uint32_t)pb0.r32);
}
printf("\n=== Port 0 ===\n");
@@ -482,7 +482,7 @@ int main(int argc, char const *argv[])
string target_type_help;
string target_name_help;
std::list<std::string> target_options;
- for (int i = 0; i < ARRAY_ELEMENTS(gStorage); i++)
+ for (size_t i = 0; i < ARRAY_ELEMENTS(gStorage); i++)
{
target_type_help += gStorage[i].type;
target_type_help += ": ";
@@ -543,7 +543,7 @@ int main(int argc, char const *argv[])
vector<string> args = parser.args();
storage_t *target = NULL;
- for (int i = 0; i < ARRAY_ELEMENTS(gStorage); i++)
+ for (size_t i = 0; i < ARRAY_ELEMENTS(gStorage); i++)
{
if (gStorage[i].type == options["target_type"])
{
@@ -768,7 +768,7 @@ int main(int argc, char const *argv[])
}
}
- for (int i = 0; i < ARRAY_ELEMENTS(nvram.contents.directory); i++)
+ for (size_t i = 0; i < ARRAY_ELEMENTS(nvram.contents.directory); i++)
{
char *cd_name = NULL;
if (extract)
@@ -821,7 +821,7 @@ int main(int argc, char const *argv[])
if (gApeWd[0] == APE_HEADER_MAGIC)
{
// Ensure everything is in the correct endianness.
- for (int i = 0; i < (new_ape_length - 4) / 4; i++)
+ for (uint32_t i = 0; i < (new_ape_length - 4) / 4; i++)
{
gApeWd[i] = be32toh(gApeWd[i]);
}
diff --git a/utils/bcmregtool/main.cpp b/utils/bcmregtool/main.cpp
index 0896b00..5eb2c4c 100644
--- a/utils/bcmregtool/main.cpp
+++ b/utils/bcmregtool/main.cpp
@@ -233,11 +233,11 @@ void print_context(void)
printf(" pc: 0x%08X (%s+%d) opcode: 0x%08X \n", pc, symbol.c_str(), sym_offset, opcode);
int numCols = 4;
int offset = 32 / numCols;
- for (int i = 0; i < ARRAY_ELEMENTS(r) / 4; i++)
+ for (size_t i = 0; i < ARRAY_ELEMENTS(r) / 4; i++)
{
for (int j = 0; j < numCols; j++)
{
- printf("$%d(%5s): 0x%08X ", i + j * offset, regnames[i + j * offset], r[i + j * offset]);
+ printf("$%zd(%5s): 0x%08X ", i + j * offset, regnames[i + j * offset], r[i + j * offset]);
}
printf("\n");
}
diff --git a/utils/elf2ape/main.cpp b/utils/elf2ape/main.cpp
index 78c95a5..c73975f 100644
--- a/utils/elf2ape/main.cpp
+++ b/utils/elf2ape/main.cpp
@@ -284,7 +284,12 @@ int main(int argc, char const *argv[])
if (options.is_set("name"))
{
string name = options["name"];
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpragmas" // Ignore Wunknown-warning-option error on GCC
+#pragma GCC diagnostic ignored "-Wunknown-warning-option" // Ignore Wstringop-truncation on Clang
+#pragma GCC diagnostic ignored "-Wstringop-truncation" // Ignore destination size not allowing a null terminator
strncpy((char *)ape.header.name, name.c_str(), sizeof(ape.header.name));
+#pragma GCC diagnostic pop
}
uint8_t version_major = get_symbol_value("VERSION_MAJOR", reader);
@@ -302,7 +307,7 @@ int main(int argc, char const *argv[])
printf("UNK0: 0x%08X\n", ape.header.unk0);
char name[sizeof(ape.header.name) + 1] = { 0 };
- strncpy(name, (char *)ape.header.name, sizeof(ape.header.name));
+ strncpy(name, (char *)ape.header.name, sizeof(name) - 1);
printf("Name: %s\n", name);
printf("Version: 0x%08X (%d.%d.%d)\n", ape.header.version, version_major, version_minor, version_patch);
printf("Start: 0x%08X\n", ape.header.entrypoint);
OpenPOWER on IntegriCloud