Skip to content

Commit

Permalink
[build]: Fix format string for size_t (sonic-net#1576)
Browse files Browse the repository at this point in the history
We met below error message in armhf build (32-bit)
```
g++ -DHAVE_CONFIG_H -I. -I.. -I ../lib -I .. -I ../warmrestart -I flex_counter -I debug_counter -g -DNDEBUG  -std=c++14 -Wall -fPIC -Wno-write-strings -I/usr/include/libnl3 -I/usr/include/swss -Werror -Wno-reorder -Wcast-align -Wcast-qual -Wconversion -Wdisabled-optimization -Wextra -Wfloat-equal -Wformat=2 -Wformat-nonliteral -Wformat-security -Wformat-y2k -Wimport -Winit-self -Winvalid-pch -Wlong-long -Wmissing-field-initializers -Wmissing-format-attribute -Wno-aggregate-return -Wno-padded -Wno-switch-enum -Wno-unused-parameter -Wpacked -Wpointer-arith -Wredundant-decls -Wstack-protector -Wstrict-aliasing=3 -Wswitch -Wswitch-default -Wunreachable-code -Wunused -Wvariadic-macros -Wno-switch-default -Wno-long-long -Wno-redundant-decls -I /usr/include/sai -Wdate-time -D_FORTIFY_SOURCE=2  -g -O2 -fdebug-prefix-map=/__w/1/s=. -fstack-protector-strong -Wformat -Werror=format-security -c -o orchagent-copporch.o `test -f 'copporch.cpp' || echo './'`copporch.cpp
In file included from /usr/include/swss/redistran.h:7,
                 from /usr/include/swss/table.h:17,
                 from orch.h:17,
                 from fgnhgorch.h:4,
                 from fgnhgorch.cpp:3:
fgnhgorch.cpp: In member function 'virtual bool FgNhgOrch::bake()':
/usr/include/swss/logger.h:17:101: error: format '%lu' expects argument of type 'long unsigned int', but argument 5 has type 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'unsigned int'} [-Werror=format=]
 #define SWSS_LOG_NOTICE(MSG, ...)      swss::Logger::getInstance().write(swss::Logger::SWSS_NOTICE, ":- %s: " MSG, __FUNCTION__, ##__VA_ARGS__)
fgnhgorch.cpp:117:5: note: in expansion of macro 'SWSS_LOG_NOTICE'
     SWSS_LOG_NOTICE("Warm reboot: recovering entry %lu from state", keys.size());
     ^~~~~~~~~~~~~~~
In file included from /usr/include/c++/8/vector:69,
                 from acltable.h:10,
                 from portsorch.h:6,
                 from portsorch.cpp:1:
```
  • Loading branch information
qiluo-msft committed Jan 1, 2021
1 parent 7ba4e43 commit 773238b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion orchagent/fgnhgorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ bool FgNhgOrch::bake()
vector<string> keys;
m_stateWarmRestartRouteTable.getKeys(keys);

SWSS_LOG_NOTICE("Warm reboot: recovering entry %lu from state", keys.size());
SWSS_LOG_NOTICE("Warm reboot: recovering entry %zu from state", keys.size());

for (const auto &key : keys)
{
Expand Down

0 comments on commit 773238b

Please sign in to comment.