From 773238b1434731d4db952ac2faf04935038a27fd Mon Sep 17 00:00:00 2001 From: Qi Luo Date: Thu, 31 Dec 2020 17:42:16 -0800 Subject: [PATCH] [build]: Fix format string for size_t (#1576) 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 >::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: ``` --- orchagent/fgnhgorch.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/orchagent/fgnhgorch.cpp b/orchagent/fgnhgorch.cpp index 051f59d51e9b..61012bef630e 100644 --- a/orchagent/fgnhgorch.cpp +++ b/orchagent/fgnhgorch.cpp @@ -114,7 +114,7 @@ bool FgNhgOrch::bake() vector 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) {