EAL: add format(printf) attrib. to appropriate fns
PATCH 1/1 EAL: add format(printf) attrib. to appropriate fns
Mark the rte_log, cmdline_printf and rte_snprintf functions as being printf-style functions. This causes compilation errors due to mis-matched parameter types, so the parameter types are fixed where appropriate.
--- app/cmdline_test/commands.c | 2 +- app/test/test_cmdline_etheraddr.c | 2 +- app/test/test_eal_flags.c | 3 ++- app/test/test_mp_secondary.c | 3 ++- examples/exception_path/main.c | 4 +-- examples/netmap_compat/lib/compat_netmap.c | 8 +++--- examples/qos_sched/args.c | 12 ++++++--- examples/qos_sched/init.c | 17 ++++++------- examples/qos_sched/main.c | 34 ++++++++++++++------------ lib/librte_cmdline/cmdline.h | 3 ++- lib/librte_eal/common/include/rte_log.h | 3 ++- lib/librte_eal/common/include/rte_string_fns.h | 3 ++- lib/librte_kni/rte_kni.c | 8 +++--- 13 files changed, 57 insertions(+), 45 deletions(-)
app/cmdline_test/commands.c +1 -1
@@ -321,7 +321,7 @@ cmd_get_history_bufsize_parsed(__attribute__((unused)) void *parsed_result, struct cmdline *cl, __attribute__((unused)) void *data) { - cmdline_printf(cl, "History buffer size: %u\n", + cmdline_printf(cl, "History buffer size: %zu\n", sizeof(cl->rdl.history_buf)); }
app/test/test_cmdline_etheraddr.c +1 -1
@@ -147,7 +147,7 @@ test_parse_etheraddr_invalid_param(void)/* copy string to buffer */ rte_snprintf (buf,sizeof (buf),"%s" , - ether_addr_valid_strs[0 ]); + ether_addr_valid_strs[0 ].str); ret =cmdline_parse_etheraddr (NULL , buf,NULL );if (ret ==-1 ) {
app/test/test_eal_flags.c +2 -1
@@ -268,7 +268,8 @@ get_current_prefix(char * prefix, int size)/* copy string all the way from second char up to start of _config */ rte_snprintf (prefix, size,"%.*s" , -strnlen (buf,sizeof (buf)) -sizeof ("_config" ), &buf[1 ]); + (int )(strnlen (buf,sizeof (buf)) -sizeof ("_config" )), + &buf[1 ]);return prefix; }
app/test/test_mp_secondary.c +2 -1
@@ -103,7 +103,8 @@ get_current_prefix(char * prefix, int size)/* copy string all the way from second char up to start of _config */ rte_snprintf (prefix, size,"%.*s" , -strnlen (buf,sizeof (buf)) -sizeof ("_config" ), &buf[1 ]); + (int )(strnlen (buf,sizeof (buf)) -sizeof ("_config" )), + &buf[1 ]);return prefix; }
examples/exception_path/main.c +2 -2
@@ -229,7 +229,7 @@ static int tap_create(char *name) ifr.ifr_flags =IFF_TAP |IFF_NO_PI ;if (name && *name) -rte_snprintf (ifr.ifr_name,IFNAMSIZ , name); +rte_snprintf (ifr.ifr_name,IFNAMSIZ ,"%s" , name); ret =ioctl (fd,TUNSETIFF , (void *) &ifr);if (ret <0 ) {
@@ -238,7 +238,7 @@ static int tap_create(char *name) }if (name) -rte_snprintf (name,IFNAMSIZ , ifr.ifr_name); +rte_snprintf (name,IFNAMSIZ ,"%s" , ifr.ifr_name);return fd; }
examples/netmap_compat/lib/compat_netmap.c +4 -4
@@ -717,8 +717,8 @@ rte_netmap_init_port(uint8_t portid, const struct rte_netmap_port_conf *conf)if (ret <0 ) {RTE_LOG (ERR ,USER1 , -"Couldn't configure TX queue %hhu of " -"port %hu\n" , +"Couldn't configure TX queue %" PRIu16" of " +"port %" PRIu8"\n" , i, portid);return (ret); }
@@ -728,8 +728,8 @@ rte_netmap_init_port(uint8_t portid, const struct rte_netmap_port_conf *conf)if (ret <0 ) {RTE_LOG (ERR ,USER1 , -"Couldn't configure RX queue %hu of " -"port %hhu\n" , +"Couldn't configure RX queue %" PRIu16" of " +"port %" PRIu8"\n" , i, portid);return (ret); }
examples/qos_sched/args.c +8 -4
@@ -264,17 +264,20 @@ app_parse_flow_conf(const char *conf_str) }if (pconf->rx_port >=RTE_MAX_ETHPORTS ) { -RTE_LOG (ERR ,APP ,"pfc %u: invalid rx port %hu index\n" , nb_pfc, pconf->rx_port); +RTE_LOG (ERR ,APP ,"pfc %u: invalid rx port %" PRIu8" index\n" , + nb_pfc, pconf->rx_port);return -1 ; }if (pconf->tx_port >=RTE_MAX_ETHPORTS ) { -RTE_LOG (ERR ,APP ,"pfc %u: invalid tx port %hu index\n" , nb_pfc, pconf->rx_port); +RTE_LOG (ERR ,APP ,"pfc %u: invalid tx port %" PRIu8" index\n" , + nb_pfc, pconf->rx_port);return -1 ; } mask =1lu << pconf->rx_port;if (app_used_rx_port_mask & mask) { -RTE_LOG (ERR ,APP ,"pfc %u: rx port %hu is used already\n" , nb_pfc, pconf->rx_port); +RTE_LOG (ERR ,APP ,"pfc %u: rx port %" PRIu8" is used already\n" , + nb_pfc, pconf->rx_port);return -1 ; } app_used_rx_port_mask |= mask;
@@ -282,7 +285,8 @@ app_parse_flow_conf(const char *conf_str) mask =1lu << pconf->tx_port;if (app_used_tx_port_mask & mask) { -RTE_LOG (ERR ,APP ,"pfc %u: port %hu is used already\n" , nb_pfc, pconf->tx_port); +RTE_LOG (ERR ,APP ,"pfc %u: port %" PRIu8" is used already\n" , + nb_pfc, pconf->tx_port);return -1 ; } app_used_tx_port_mask |= mask;
examples/qos_sched/init.c +8 -9
@@ -124,20 +124,20 @@ app_init_port(uint8_t portid, struct rte_mempool *mp) tx_conf.txq_flags =ETH_TXQ_FLAGS_NOMULTSEGS |ETH_TXQ_FLAGS_NOOFFLOADS ;/* init port */ -RTE_LOG (INFO ,APP ,"Initializing port %hu... " , portid); +RTE_LOG (INFO ,APP ,"Initializing port %" PRIu8"... " , portid);fflush (stdout); ret =rte_eth_dev_configure (portid,1 ,1 , &port_conf);if (ret <0 ) -rte_exit (EXIT_FAILURE ,"Cannot configure device: err=%d, port=%hu\n" , - ret, portid); +rte_exit (EXIT_FAILURE ,"Cannot configure device: " +"err=%d, port=%" PRIu8"\n" , ret, portid);/* init one RX queue */ fflush (stdout); ret =rte_eth_rx_queue_setup (portid,0 , (uint16_t )ring_conf.rx_size,rte_eth_dev_socket_id (portid), &rx_conf, mp);if (ret <0 ) -rte_exit (EXIT_FAILURE ,"rte_eth_tx_queue_setup: err=%d, port=%hu\n" , - ret, portid); +rte_exit (EXIT_FAILURE ,"rte_eth_tx_queue_setup: " +"err=%d, port=%" PRIu8"\n" , ret, portid);/* init one TX queue */ fflush (stdout);
@@ -145,14 +145,13 @@ app_init_port(uint8_t portid, struct rte_mempool *mp) (uint16_t)ring_conf.tx_size, rte_eth_dev_socket_id(portid), &tx_conf);if (ret <0 )rte_exit (EXIT_FAILURE ,"rte_eth_tx_queue_setup: err=%d, " -"port=%hu queue=%d\n" , - ret, portid,0 ); +"port=%" PRIu8" queue=%d\n" , ret, portid,0 );/* Start device */ ret =rte_eth_dev_start (portid);if (ret <0 ) -rte_exit (EXIT_FAILURE ,"rte_pmd_port_start: err=%d, port=%hu\n" , - ret, portid); +rte_exit (EXIT_FAILURE ,"rte_pmd_port_start: " +"err=%d, port=%" PRIu8"\n" , ret, portid);printf ("done: " );
examples/qos_sched/main.c +19 -15
@@ -125,8 +125,9 @@ app_main_loop(__attribute__((unused))void *dummy)/* initialize mbuf memory */ if (mode ==APP_RX_MODE ) {for (i =0 ; i < rx_idx; i++) { -RTE_LOG (INFO ,APP ,"flow %u lcoreid %u reading port %hu\n" , - i, lcore_id, rx_confs[i]->rx_port); +RTE_LOG (INFO ,APP ,"flow %u lcoreid %u " +"reading port %" PRIu8"\n" , + i, lcore_id, rx_confs[i]->rx_port); }app_rx_thread (rx_confs);
@@ -139,8 +140,9 @@ app_main_loop(__attribute__((unused))void *dummy)if (wt_confs[i]->m_table ==NULL )rte_panic ("flow %u unable to allocate memory buffer\n" , i); -RTE_LOG (INFO ,APP ,"flow %u lcoreid %u sched+write port %hu\n" , - i, lcore_id, wt_confs[i]->tx_port); +RTE_LOG (INFO ,APP ,"flow %u lcoreid %u sched+write " +"port %" PRIu8"\n" , + i, lcore_id, wt_confs[i]->tx_port); }app_mixed_thread (wt_confs);
@@ -153,8 +155,9 @@ app_main_loop(__attribute__((unused))void *dummy)if (tx_confs[i]->m_table ==NULL )rte_panic ("flow %u unable to allocate memory buffer\n" , i); -RTE_LOG (INFO ,APP ,"flow %u lcoreid %u writing port %hu\n" , - i, lcore_id, tx_confs[i]->tx_port); +RTE_LOG (INFO ,APP ,"flow %u lcoreid %u " +"writing port %" PRIu8"\n" , + i, lcore_id, tx_confs[i]->tx_port); }app_tx_thread (tx_confs);
@@ -183,18 +186,19 @@ app_stat(void)struct flow_conf *flow = &qos_conf[i];rte_eth_stats_get (flow->rx_port, &stats); -printf ("\nRX port %hu: rx: %" PRIu64" err: %" PRIu64" no_mbuf: %" PRIu64"\n" , - flow->rx_port, - stats.ipackets - rx_stats[i].ipackets, - stats.ierrors - rx_stats[i].ierrors, - stats.rx_nombuf - rx_stats[i].rx_nombuf); +printf ("\nRX port %" PRIu8": rx: %" PRIu64" err: %" PRIu64 +" no_mbuf: %" PRIu64"\n" , + flow->rx_port, + stats.ipackets - rx_stats[i].ipackets, + stats.ierrors - rx_stats[i].ierrors, + stats.rx_nombuf - rx_stats[i].rx_nombuf);memcpy (&rx_stats[i], &stats,sizeof (stats));rte_eth_stats_get (flow->tx_port, &stats); -printf ("TX port %hu: tx: %" PRIu64" err: %" PRIu64"\n" , - flow->tx_port, - stats.opackets - tx_stats[i].opackets, - stats.oerrors - tx_stats[i].oerrors); +printf ("TX port %" PRIu8": tx: %" PRIu64" err: %" PRIu64"\n" , + flow->tx_port, + stats.opackets - tx_stats[i].opackets, + stats.oerrors - tx_stats[i].oerrors);memcpy (&tx_stats[i], &stats,sizeof (stats));//printf("MP = %d\n", rte_mempool_count(conf->app_pktmbuf_pool));
lib/librte_cmdline/cmdline.h +2 -1
@@ -79,7 +79,8 @@ struct cmdline {struct cmdline *cmdline_new (cmdline_parse_ctx_t *ctx,const char *prompt,int s_in,int s_out);void cmdline_set_prompt (struct cmdline *cl,const char *prompt);void cmdline_free (struct cmdline *cl); -void cmdline_printf (const struct cmdline *cl,const char *fmt, ...); +void cmdline_printf (const struct cmdline *cl,const char *fmt, ...) + __attribute__((format (printf,2 ,3 )));int cmdline_in (struct cmdline *cl,const char *buf,int size);int cmdline_write_char (struct rdline *rdl,char c);void cmdline_interact (struct cmdline *cl);
lib/librte_eal/common/include/rte_log.h +2 -1
@@ -258,7 +258,8 @@ int rte_log(uint32_t level, uint32_t logtype, const char *format, ...)* - 0: Success. * - Negative on error. */ -int rte_vlog (uint32_t level,uint32_t logtype,const char *format,va_list ap); +int rte_vlog (uint32_t level,uint32_t logtype,const char *format,va_list ap) + __attribute__((format (printf,3 ,0 )));/** * Generates a log message.
lib/librte_eal/common/include/rte_string_fns.h +2 -1
@@ -68,7 +68,8 @@ extern "C" {* */ int -rte_snprintf (char *buffer,int buflen,const char *format, ...); +rte_snprintf (char *buffer,int buflen,const char *format, ...) + __attribute__((format (printf,3 ,4 )));/** * Takes string "string" parameter and splits it at character "delim"
lib/librte_kni/rte_kni.c +4 -4
@@ -158,7 +158,7 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool, } } -rte_snprintf (intf_name,RTE_KNI_NAMESIZE , conf->name); +rte_snprintf (intf_name,RTE_KNI_NAMESIZE ,"%s" , conf->name);rte_snprintf (mz_name,RTE_MEMZONE_NAMESIZE ,"KNI_INFO_%s" , intf_name); mz =kni_memzone_reserve (mz_name,sizeof (struct rte_kni ),SOCKET_ID_ANY ,0 );
@@ -184,8 +184,8 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool, dev_info.group_id = conf->group_id; dev_info.mbuf_size = conf->mbuf_size; -rte_snprintf (ctx->name,RTE_KNI_NAMESIZE , intf_name); -rte_snprintf (dev_info.name,RTE_KNI_NAMESIZE , intf_name); +rte_snprintf (ctx->name,RTE_KNI_NAMESIZE ,"%s" , intf_name); +rte_snprintf (dev_info.name,RTE_KNI_NAMESIZE ,"%s" , intf_name); RTE_LOG(INFO, KNI, "pci: %02x:%02x:%02x \t %02x:%02x\n", dev_info.bus, dev_info.devid, dev_info.function,
@@ -291,7 +291,7 @@ rte_kni_release(struct rte_kni *kni)if (!kni || !kni->in_use)return -1 ; -rte_snprintf (dev_info.name,sizeof (dev_info.name), kni->name); +rte_snprintf (dev_info.name,sizeof (dev_info.name),"%s" , kni->name);if (ioctl (kni_fd,RTE_KNI_IOCTL_RELEASE , &dev_info) <0 ) {RTE_LOG (ERR ,KNI ,"Fail to release kni device\n" );return -1 ;
Signature · 1 line
1.9.3
2014-06-17 19:42, Bruce Richardson:
Quoted 6 lines
Mark the
rte_log,cmdline_printfandrte_snprintffunctions as being printf-style functions. This causes compilation errors due to mis-matched parameter types, so the parameter types are fixed where appropriate.Signed-off-by Bruce Richardson <[email protected]>
Nice cleanup.
2 comments:
- I think title should be "fix usage of printf-like functions"
- there are some errors in ivshmem code
Signature · 1 line
Thomas
PATCH v2 1/1 EAL: fix usage of printf-like functions
Mark the rte_log, cmdline_printf and rte_snprintf functions as being printf-style functions. This causes compilation errors due to mis-matched parameter types, so the parameter types are fixed where appropriate.
Changes in V2:
* Additional fixes for ivshmem-target compilation
--- app/cmdline_test/commands.c | 2 +- app/test/test_cmdline_etheraddr.c | 2 +- app/test/test_eal_flags.c | 3 ++- app/test/test_ivshmem.c | 3 ++- app/test/test_mp_secondary.c | 3 ++- examples/exception_path/main.c | 4 +-- examples/netmap_compat/lib/compat_netmap.c | 8 +++--- examples/qos_sched/args.c | 12 ++++++--- examples/qos_sched/init.c | 17 ++++++------- examples/qos_sched/main.c | 34 ++++++++++++++------------ lib/librte_cmdline/cmdline.h | 3 ++- lib/librte_eal/common/include/rte_log.h | 3 ++- lib/librte_eal/common/include/rte_string_fns.h | 3 ++- lib/librte_eal/linuxapp/eal/eal_ivshmem.c | 2 +- lib/librte_ivshmem/rte_ivshmem.c | 4 +-- lib/librte_kni/rte_kni.c | 8 +++--- 16 files changed, 62 insertions(+), 49 deletions(-)
app/cmdline_test/commands.c +1 -1
@@ -321,7 +321,7 @@ cmd_get_history_bufsize_parsed(__attribute__((unused)) void *parsed_result, struct cmdline *cl, __attribute__((unused)) void *data) { - cmdline_printf(cl, "History buffer size: %u\n", + cmdline_printf(cl, "History buffer size: %zu\n", sizeof(cl->rdl.history_buf)); }
app/test/test_cmdline_etheraddr.c +1 -1
@@ -147,7 +147,7 @@ test_parse_etheraddr_invalid_param(void)/* copy string to buffer */ rte_snprintf (buf,sizeof (buf),"%s" , - ether_addr_valid_strs[0 ]); + ether_addr_valid_strs[0 ].str); ret =cmdline_parse_etheraddr (NULL , buf,NULL );if (ret ==-1 ) {
app/test/test_eal_flags.c +2 -1
@@ -268,7 +268,8 @@ get_current_prefix(char * prefix, int size)/* copy string all the way from second char up to start of _config */ rte_snprintf (prefix, size,"%.*s" , -strnlen (buf,sizeof (buf)) -sizeof ("_config" ), &buf[1 ]); + (int )(strnlen (buf,sizeof (buf)) -sizeof ("_config" )), + &buf[1 ]);return prefix; }
app/test/test_ivshmem.c +2 -1
@@ -84,7 +84,8 @@ get_current_prefix(char * prefix, int size)/* copy string all the way from second char up to start of _config */ rte_snprintf (prefix, size,"%.*s" , -strnlen (buf,sizeof (buf)) -sizeof ("_config" ), &buf[1 ]); + (int )(strnlen (buf,sizeof (buf)) -sizeof ("_config" )), + &buf[1 ]);return prefix; }
app/test/test_mp_secondary.c +2 -1
@@ -103,7 +103,8 @@ get_current_prefix(char * prefix, int size)/* copy string all the way from second char up to start of _config */ rte_snprintf (prefix, size,"%.*s" , -strnlen (buf,sizeof (buf)) -sizeof ("_config" ), &buf[1 ]); + (int )(strnlen (buf,sizeof (buf)) -sizeof ("_config" )), + &buf[1 ]);return prefix; }
examples/exception_path/main.c +2 -2
@@ -229,7 +229,7 @@ static int tap_create(char *name) ifr.ifr_flags =IFF_TAP |IFF_NO_PI ;if (name && *name) -rte_snprintf (ifr.ifr_name,IFNAMSIZ , name); +rte_snprintf (ifr.ifr_name,IFNAMSIZ ,"%s" , name); ret =ioctl (fd,TUNSETIFF , (void *) &ifr);if (ret <0 ) {
@@ -238,7 +238,7 @@ static int tap_create(char *name) }if (name) -rte_snprintf (name,IFNAMSIZ , ifr.ifr_name); +rte_snprintf (name,IFNAMSIZ ,"%s" , ifr.ifr_name);return fd; }
examples/netmap_compat/lib/compat_netmap.c +4 -4
@@ -717,8 +717,8 @@ rte_netmap_init_port(uint8_t portid, const struct rte_netmap_port_conf *conf)if (ret <0 ) {RTE_LOG (ERR ,USER1 , -"Couldn't configure TX queue %hhu of " -"port %hu\n" , +"Couldn't configure TX queue %" PRIu16" of " +"port %" PRIu8"\n" , i, portid);return (ret); }
@@ -728,8 +728,8 @@ rte_netmap_init_port(uint8_t portid, const struct rte_netmap_port_conf *conf)if (ret <0 ) {RTE_LOG (ERR ,USER1 , -"Couldn't configure RX queue %hu of " -"port %hhu\n" , +"Couldn't configure RX queue %" PRIu16" of " +"port %" PRIu8"\n" , i, portid);return (ret); }
examples/qos_sched/args.c +8 -4
@@ -264,17 +264,20 @@ app_parse_flow_conf(const char *conf_str) }if (pconf->rx_port >=RTE_MAX_ETHPORTS ) { -RTE_LOG (ERR ,APP ,"pfc %u: invalid rx port %hu index\n" , nb_pfc, pconf->rx_port); +RTE_LOG (ERR ,APP ,"pfc %u: invalid rx port %" PRIu8" index\n" , + nb_pfc, pconf->rx_port);return -1 ; }if (pconf->tx_port >=RTE_MAX_ETHPORTS ) { -RTE_LOG (ERR ,APP ,"pfc %u: invalid tx port %hu index\n" , nb_pfc, pconf->rx_port); +RTE_LOG (ERR ,APP ,"pfc %u: invalid tx port %" PRIu8" index\n" , + nb_pfc, pconf->rx_port);return -1 ; } mask =1lu << pconf->rx_port;if (app_used_rx_port_mask & mask) { -RTE_LOG (ERR ,APP ,"pfc %u: rx port %hu is used already\n" , nb_pfc, pconf->rx_port); +RTE_LOG (ERR ,APP ,"pfc %u: rx port %" PRIu8" is used already\n" , + nb_pfc, pconf->rx_port);return -1 ; } app_used_rx_port_mask |= mask;
@@ -282,7 +285,8 @@ app_parse_flow_conf(const char *conf_str) mask =1lu << pconf->tx_port;if (app_used_tx_port_mask & mask) { -RTE_LOG (ERR ,APP ,"pfc %u: port %hu is used already\n" , nb_pfc, pconf->tx_port); +RTE_LOG (ERR ,APP ,"pfc %u: port %" PRIu8" is used already\n" , + nb_pfc, pconf->tx_port);return -1 ; } app_used_tx_port_mask |= mask;
examples/qos_sched/init.c +8 -9
@@ -124,20 +124,20 @@ app_init_port(uint8_t portid, struct rte_mempool *mp) tx_conf.txq_flags =ETH_TXQ_FLAGS_NOMULTSEGS |ETH_TXQ_FLAGS_NOOFFLOADS ;/* init port */ -RTE_LOG (INFO ,APP ,"Initializing port %hu... " , portid); +RTE_LOG (INFO ,APP ,"Initializing port %" PRIu8"... " , portid);fflush (stdout); ret =rte_eth_dev_configure (portid,1 ,1 , &port_conf);if (ret <0 ) -rte_exit (EXIT_FAILURE ,"Cannot configure device: err=%d, port=%hu\n" , - ret, portid); +rte_exit (EXIT_FAILURE ,"Cannot configure device: " +"err=%d, port=%" PRIu8"\n" , ret, portid);/* init one RX queue */ fflush (stdout); ret =rte_eth_rx_queue_setup (portid,0 , (uint16_t )ring_conf.rx_size,rte_eth_dev_socket_id (portid), &rx_conf, mp);if (ret <0 ) -rte_exit (EXIT_FAILURE ,"rte_eth_tx_queue_setup: err=%d, port=%hu\n" , - ret, portid); +rte_exit (EXIT_FAILURE ,"rte_eth_tx_queue_setup: " +"err=%d, port=%" PRIu8"\n" , ret, portid);/* init one TX queue */ fflush (stdout);
@@ -145,14 +145,13 @@ app_init_port(uint8_t portid, struct rte_mempool *mp) (uint16_t)ring_conf.tx_size, rte_eth_dev_socket_id(portid), &tx_conf);if (ret <0 )rte_exit (EXIT_FAILURE ,"rte_eth_tx_queue_setup: err=%d, " -"port=%hu queue=%d\n" , - ret, portid,0 ); +"port=%" PRIu8" queue=%d\n" , ret, portid,0 );/* Start device */ ret =rte_eth_dev_start (portid);if (ret <0 ) -rte_exit (EXIT_FAILURE ,"rte_pmd_port_start: err=%d, port=%hu\n" , - ret, portid); +rte_exit (EXIT_FAILURE ,"rte_pmd_port_start: " +"err=%d, port=%" PRIu8"\n" , ret, portid);printf ("done: " );
examples/qos_sched/main.c +19 -15
@@ -125,8 +125,9 @@ app_main_loop(__attribute__((unused))void *dummy)/* initialize mbuf memory */ if (mode ==APP_RX_MODE ) {for (i =0 ; i < rx_idx; i++) { -RTE_LOG (INFO ,APP ,"flow %u lcoreid %u reading port %hu\n" , - i, lcore_id, rx_confs[i]->rx_port); +RTE_LOG (INFO ,APP ,"flow %u lcoreid %u " +"reading port %" PRIu8"\n" , + i, lcore_id, rx_confs[i]->rx_port); }app_rx_thread (rx_confs);
@@ -139,8 +140,9 @@ app_main_loop(__attribute__((unused))void *dummy)if (wt_confs[i]->m_table ==NULL )rte_panic ("flow %u unable to allocate memory buffer\n" , i); -RTE_LOG (INFO ,APP ,"flow %u lcoreid %u sched+write port %hu\n" , - i, lcore_id, wt_confs[i]->tx_port); +RTE_LOG (INFO ,APP ,"flow %u lcoreid %u sched+write " +"port %" PRIu8"\n" , + i, lcore_id, wt_confs[i]->tx_port); }app_mixed_thread (wt_confs);
@@ -153,8 +155,9 @@ app_main_loop(__attribute__((unused))void *dummy)if (tx_confs[i]->m_table ==NULL )rte_panic ("flow %u unable to allocate memory buffer\n" , i); -RTE_LOG (INFO ,APP ,"flow %u lcoreid %u writing port %hu\n" , - i, lcore_id, tx_confs[i]->tx_port); +RTE_LOG (INFO ,APP ,"flow %u lcoreid %u " +"writing port %" PRIu8"\n" , + i, lcore_id, tx_confs[i]->tx_port); }app_tx_thread (tx_confs);
@@ -183,18 +186,19 @@ app_stat(void)struct flow_conf *flow = &qos_conf[i];rte_eth_stats_get (flow->rx_port, &stats); -printf ("\nRX port %hu: rx: %" PRIu64" err: %" PRIu64" no_mbuf: %" PRIu64"\n" , - flow->rx_port, - stats.ipackets - rx_stats[i].ipackets, - stats.ierrors - rx_stats[i].ierrors, - stats.rx_nombuf - rx_stats[i].rx_nombuf); +printf ("\nRX port %" PRIu8": rx: %" PRIu64" err: %" PRIu64 +" no_mbuf: %" PRIu64"\n" , + flow->rx_port, + stats.ipackets - rx_stats[i].ipackets, + stats.ierrors - rx_stats[i].ierrors, + stats.rx_nombuf - rx_stats[i].rx_nombuf);memcpy (&rx_stats[i], &stats,sizeof (stats));rte_eth_stats_get (flow->tx_port, &stats); -printf ("TX port %hu: tx: %" PRIu64" err: %" PRIu64"\n" , - flow->tx_port, - stats.opackets - tx_stats[i].opackets, - stats.oerrors - tx_stats[i].oerrors); +printf ("TX port %" PRIu8": tx: %" PRIu64" err: %" PRIu64"\n" , + flow->tx_port, + stats.opackets - tx_stats[i].opackets, + stats.oerrors - tx_stats[i].oerrors);memcpy (&tx_stats[i], &stats,sizeof (stats));//printf("MP = %d\n", rte_mempool_count(conf->app_pktmbuf_pool));
lib/librte_cmdline/cmdline.h +2 -1
@@ -79,7 +79,8 @@ struct cmdline {struct cmdline *cmdline_new (cmdline_parse_ctx_t *ctx,const char *prompt,int s_in,int s_out);void cmdline_set_prompt (struct cmdline *cl,const char *prompt);void cmdline_free (struct cmdline *cl); -void cmdline_printf (const struct cmdline *cl,const char *fmt, ...); +void cmdline_printf (const struct cmdline *cl,const char *fmt, ...) + __attribute__((format (printf,2 ,3 )));int cmdline_in (struct cmdline *cl,const char *buf,int size);int cmdline_write_char (struct rdline *rdl,char c);void cmdline_interact (struct cmdline *cl);
lib/librte_eal/common/include/rte_log.h +2 -1
@@ -258,7 +258,8 @@ int rte_log(uint32_t level, uint32_t logtype, const char *format, ...)* - 0: Success. * - Negative on error. */ -int rte_vlog (uint32_t level,uint32_t logtype,const char *format,va_list ap); +int rte_vlog (uint32_t level,uint32_t logtype,const char *format,va_list ap) + __attribute__((format (printf,3 ,0 )));/** * Generates a log message.
lib/librte_eal/common/include/rte_string_fns.h +2 -1
@@ -68,7 +68,8 @@ extern "C" {* */ int -rte_snprintf (char *buffer,int buflen,const char *format, ...); +rte_snprintf (char *buffer,int buflen,const char *format, ...) + __attribute__((format (printf,3 ,4 )));/** * Takes string "string" parameter and splits it at character "delim"
lib/librte_eal/linuxapp/eal/eal_ivshmem.c +1 -1
@@ -918,7 +918,7 @@ int rte_eal_ivshmem_init(void) ivshmem_config->pci_devs[ivshmem_config->pci_devs_idx].ioremap_addr = res->phys_addr;rte_snprintf (ivshmem_config->pci_devs[ivshmem_config->pci_devs_idx].path,sizeof (ivshmem_config->pci_devs[ivshmem_config->pci_devs_idx].path), - path); +"%s" , path); ivshmem_config->pci_devs_idx++; }
lib/librte_ivshmem/rte_ivshmem.c +2 -2
@@ -777,7 +777,7 @@ rte_ivshmem_metadata_cmdline_generate(char *buffer, unsigned size, const char *n/* add /dev/zero to command-line to fill the space */ tmplen =rte_snprintf (cmdline_ptr, remaining_len,IVSHMEM_QEMU_CMD_FD_FMT ,"/dev/zero" , -0x0 , + (uint64_t )0x0 , zero_size); cmdline_ptr =RTE_PTR_ADD (cmdline_ptr, tmplen);
@@ -792,7 +792,7 @@ rte_ivshmem_metadata_cmdline_generate(char *buffer, unsigned size, const char *n/* add metadata file to the end of command-line */ tmplen =rte_snprintf (cmdline_ptr, remaining_len,IVSHMEM_QEMU_CMD_FD_FMT , cfg_file_path, -0x0 , + (uint64_t )0x0 ,METADATA_SIZE_ALIGNED ); cmdline_ptr =RTE_PTR_ADD (cmdline_ptr, tmplen);
lib/librte_kni/rte_kni.c +4 -4
@@ -158,7 +158,7 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool, } } -rte_snprintf (intf_name,RTE_KNI_NAMESIZE , conf->name); +rte_snprintf (intf_name,RTE_KNI_NAMESIZE ,"%s" , conf->name);rte_snprintf (mz_name,RTE_MEMZONE_NAMESIZE ,"KNI_INFO_%s" , intf_name); mz =kni_memzone_reserve (mz_name,sizeof (struct rte_kni ),SOCKET_ID_ANY ,0 );
@@ -184,8 +184,8 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool, dev_info.group_id = conf->group_id; dev_info.mbuf_size = conf->mbuf_size; -rte_snprintf (ctx->name,RTE_KNI_NAMESIZE , intf_name); -rte_snprintf (dev_info.name,RTE_KNI_NAMESIZE , intf_name); +rte_snprintf (ctx->name,RTE_KNI_NAMESIZE ,"%s" , intf_name); +rte_snprintf (dev_info.name,RTE_KNI_NAMESIZE ,"%s" , intf_name); RTE_LOG(INFO, KNI, "pci: %02x:%02x:%02x \t %02x:%02x\n", dev_info.bus, dev_info.devid, dev_info.function,
@@ -291,7 +291,7 @@ rte_kni_release(struct rte_kni *kni)if (!kni || !kni->in_use)return -1 ; -rte_snprintf (dev_info.name,sizeof (dev_info.name), kni->name); +rte_snprintf (dev_info.name,sizeof (dev_info.name),"%s" , kni->name);if (ioctl (kni_fd,RTE_KNI_IOCTL_RELEASE , &dev_info) <0 ) {RTE_LOG (ERR ,KNI ,"Fail to release kni device\n" );return -1 ;
Signature · 1 line
1.9.3
Re: [PATCH v2] EAL: fix usage of printf-like functions
In reply to a message not in the archiveQuoted 13 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Bruce Richardson
Sent: Thursday, June 19, 2014 7:22 PM
To: [email protected]
Subject: [dpdk-dev] [PATCH v2] EAL: fix usage of printf-like functionsMark the
rte_log,cmdline_printfandrte_snprintffunctions as being printf-style functions. This causes compilation errors due to mis-matched parameter types, so the parameter types are fixed where appropriate.
Quoted 5 lines
Changes in V2:
* Additional fixes for ivshmem-target compilationSigned-off-by Bruce Richardson <[email protected]>---
This patch compiles correctly before the 1.7 rc1. After it, i40e library introduces a compilation error that can be fixed by making the following change:
lib/librte_pmd_i40e/i40e_ethdev.c +1 -1
@@ -1536,7 +1536,7 @@ i40e_allocate_dma_mem_d(__attribute__((unused)) struct i40e_hw *hw,return I40E_ERR_PARAM ; id++; -rte_snprintf (z_name,sizeof (z_name),"i40e_dma_%lu" , id); +rte_snprintf (z_name,sizeof (z_name),"i40e_dma_%" PRIu64, id); mz =rte_memzone_reserve_aligned (z_name, size,0 ,0 , alignment);if (!mz)return I40E_ERR_NO_MEMORY ;
Thanks,
Pablo
PATCH v3 1/1 EAL: fix usage of printf-like functions
In reply to a message not in the archiveMark the rte_log, cmdline_printf and rte_snprintf functions as being printf-style functions. This causes compilation errors due to mis-matched parameter types, so the parameter types are fixed where appropriate.
Changes in V2:
* Additional fixes for ivshmem-target compilation
Changes in V3:
* additional printf-format fix for i40e driver as pointed out by Pablo De Lara
--- app/cmdline_test/commands.c | 2 +- app/test/test_cmdline_etheraddr.c | 2 +- app/test/test_eal_flags.c | 3 ++- app/test/test_ivshmem.c | 3 ++- app/test/test_mp_secondary.c | 3 ++- examples/exception_path/main.c | 4 +-- examples/netmap_compat/lib/compat_netmap.c | 8 +++--- examples/qos_sched/args.c | 12 ++++++--- examples/qos_sched/init.c | 17 ++++++------- examples/qos_sched/main.c | 34 ++++++++++++++------------ lib/librte_cmdline/cmdline.h | 3 ++- lib/librte_eal/common/include/rte_log.h | 3 ++- lib/librte_eal/common/include/rte_string_fns.h | 3 ++- lib/librte_eal/linuxapp/eal/eal_ivshmem.c | 2 +- lib/librte_ivshmem/rte_ivshmem.c | 4 +-- lib/librte_kni/rte_kni.c | 8 +++--- lib/librte_pmd_i40e/i40e_ethdev.c | 2 +- 17 files changed, 63 insertions(+), 50 deletions(-)
app/cmdline_test/commands.c +1 -1
@@ -321,7 +321,7 @@ cmd_get_history_bufsize_parsed(__attribute__((unused)) void *parsed_result, struct cmdline *cl, __attribute__((unused)) void *data) { - cmdline_printf(cl, "History buffer size: %u\n", + cmdline_printf(cl, "History buffer size: %zu\n", sizeof(cl->rdl.history_buf)); }
app/test/test_cmdline_etheraddr.c +1 -1
@@ -147,7 +147,7 @@ test_parse_etheraddr_invalid_param(void)/* copy string to buffer */ rte_snprintf (buf,sizeof (buf),"%s" , - ether_addr_valid_strs[0 ]); + ether_addr_valid_strs[0 ].str); ret =cmdline_parse_etheraddr (NULL , buf,NULL );if (ret ==-1 ) {
app/test/test_eal_flags.c +2 -1
@@ -268,7 +268,8 @@ get_current_prefix(char * prefix, int size)/* copy string all the way from second char up to start of _config */ rte_snprintf (prefix, size,"%.*s" , -strnlen (buf,sizeof (buf)) -sizeof ("_config" ), &buf[1 ]); + (int )(strnlen (buf,sizeof (buf)) -sizeof ("_config" )), + &buf[1 ]);return prefix; }
app/test/test_ivshmem.c +2 -1
@@ -84,7 +84,8 @@ get_current_prefix(char * prefix, int size)/* copy string all the way from second char up to start of _config */ rte_snprintf (prefix, size,"%.*s" , -strnlen (buf,sizeof (buf)) -sizeof ("_config" ), &buf[1 ]); + (int )(strnlen (buf,sizeof (buf)) -sizeof ("_config" )), + &buf[1 ]);return prefix; }
app/test/test_mp_secondary.c +2 -1
@@ -103,7 +103,8 @@ get_current_prefix(char * prefix, int size)/* copy string all the way from second char up to start of _config */ rte_snprintf (prefix, size,"%.*s" , -strnlen (buf,sizeof (buf)) -sizeof ("_config" ), &buf[1 ]); + (int )(strnlen (buf,sizeof (buf)) -sizeof ("_config" )), + &buf[1 ]);return prefix; }
examples/exception_path/main.c +2 -2
@@ -229,7 +229,7 @@ static int tap_create(char *name) ifr.ifr_flags =IFF_TAP |IFF_NO_PI ;if (name && *name) -rte_snprintf (ifr.ifr_name,IFNAMSIZ , name); +rte_snprintf (ifr.ifr_name,IFNAMSIZ ,"%s" , name); ret =ioctl (fd,TUNSETIFF , (void *) &ifr);if (ret <0 ) {
@@ -238,7 +238,7 @@ static int tap_create(char *name) }if (name) -rte_snprintf (name,IFNAMSIZ , ifr.ifr_name); +rte_snprintf (name,IFNAMSIZ ,"%s" , ifr.ifr_name);return fd; }
examples/netmap_compat/lib/compat_netmap.c +4 -4
@@ -717,8 +717,8 @@ rte_netmap_init_port(uint8_t portid, const struct rte_netmap_port_conf *conf)if (ret <0 ) {RTE_LOG (ERR ,USER1 , -"Couldn't configure TX queue %hhu of " -"port %hu\n" , +"Couldn't configure TX queue %" PRIu16" of " +"port %" PRIu8"\n" , i, portid);return (ret); }
@@ -728,8 +728,8 @@ rte_netmap_init_port(uint8_t portid, const struct rte_netmap_port_conf *conf)if (ret <0 ) {RTE_LOG (ERR ,USER1 , -"Couldn't configure RX queue %hu of " -"port %hhu\n" , +"Couldn't configure RX queue %" PRIu16" of " +"port %" PRIu8"\n" , i, portid);return (ret); }
examples/qos_sched/args.c +8 -4
@@ -264,17 +264,20 @@ app_parse_flow_conf(const char *conf_str) }if (pconf->rx_port >=RTE_MAX_ETHPORTS ) { -RTE_LOG (ERR ,APP ,"pfc %u: invalid rx port %hu index\n" , nb_pfc, pconf->rx_port); +RTE_LOG (ERR ,APP ,"pfc %u: invalid rx port %" PRIu8" index\n" , + nb_pfc, pconf->rx_port);return -1 ; }if (pconf->tx_port >=RTE_MAX_ETHPORTS ) { -RTE_LOG (ERR ,APP ,"pfc %u: invalid tx port %hu index\n" , nb_pfc, pconf->rx_port); +RTE_LOG (ERR ,APP ,"pfc %u: invalid tx port %" PRIu8" index\n" , + nb_pfc, pconf->rx_port);return -1 ; } mask =1lu << pconf->rx_port;if (app_used_rx_port_mask & mask) { -RTE_LOG (ERR ,APP ,"pfc %u: rx port %hu is used already\n" , nb_pfc, pconf->rx_port); +RTE_LOG (ERR ,APP ,"pfc %u: rx port %" PRIu8" is used already\n" , + nb_pfc, pconf->rx_port);return -1 ; } app_used_rx_port_mask |= mask;
@@ -282,7 +285,8 @@ app_parse_flow_conf(const char *conf_str) mask =1lu << pconf->tx_port;if (app_used_tx_port_mask & mask) { -RTE_LOG (ERR ,APP ,"pfc %u: port %hu is used already\n" , nb_pfc, pconf->tx_port); +RTE_LOG (ERR ,APP ,"pfc %u: port %" PRIu8" is used already\n" , + nb_pfc, pconf->tx_port);return -1 ; } app_used_tx_port_mask |= mask;
examples/qos_sched/init.c +8 -9
@@ -124,20 +124,20 @@ app_init_port(uint8_t portid, struct rte_mempool *mp) tx_conf.txq_flags =ETH_TXQ_FLAGS_NOMULTSEGS |ETH_TXQ_FLAGS_NOOFFLOADS ;/* init port */ -RTE_LOG (INFO ,APP ,"Initializing port %hu... " , portid); +RTE_LOG (INFO ,APP ,"Initializing port %" PRIu8"... " , portid);fflush (stdout); ret =rte_eth_dev_configure (portid,1 ,1 , &port_conf);if (ret <0 ) -rte_exit (EXIT_FAILURE ,"Cannot configure device: err=%d, port=%hu\n" , - ret, portid); +rte_exit (EXIT_FAILURE ,"Cannot configure device: " +"err=%d, port=%" PRIu8"\n" , ret, portid);/* init one RX queue */ fflush (stdout); ret =rte_eth_rx_queue_setup (portid,0 , (uint16_t )ring_conf.rx_size,rte_eth_dev_socket_id (portid), &rx_conf, mp);if (ret <0 ) -rte_exit (EXIT_FAILURE ,"rte_eth_tx_queue_setup: err=%d, port=%hu\n" , - ret, portid); +rte_exit (EXIT_FAILURE ,"rte_eth_tx_queue_setup: " +"err=%d, port=%" PRIu8"\n" , ret, portid);/* init one TX queue */ fflush (stdout);
@@ -145,14 +145,13 @@ app_init_port(uint8_t portid, struct rte_mempool *mp) (uint16_t)ring_conf.tx_size, rte_eth_dev_socket_id(portid), &tx_conf);if (ret <0 )rte_exit (EXIT_FAILURE ,"rte_eth_tx_queue_setup: err=%d, " -"port=%hu queue=%d\n" , - ret, portid,0 ); +"port=%" PRIu8" queue=%d\n" , ret, portid,0 );/* Start device */ ret =rte_eth_dev_start (portid);if (ret <0 ) -rte_exit (EXIT_FAILURE ,"rte_pmd_port_start: err=%d, port=%hu\n" , - ret, portid); +rte_exit (EXIT_FAILURE ,"rte_pmd_port_start: " +"err=%d, port=%" PRIu8"\n" , ret, portid);printf ("done: " );
examples/qos_sched/main.c +19 -15
@@ -125,8 +125,9 @@ app_main_loop(__attribute__((unused))void *dummy)/* initialize mbuf memory */ if (mode ==APP_RX_MODE ) {for (i =0 ; i < rx_idx; i++) { -RTE_LOG (INFO ,APP ,"flow %u lcoreid %u reading port %hu\n" , - i, lcore_id, rx_confs[i]->rx_port); +RTE_LOG (INFO ,APP ,"flow %u lcoreid %u " +"reading port %" PRIu8"\n" , + i, lcore_id, rx_confs[i]->rx_port); }app_rx_thread (rx_confs);
@@ -139,8 +140,9 @@ app_main_loop(__attribute__((unused))void *dummy)if (wt_confs[i]->m_table ==NULL )rte_panic ("flow %u unable to allocate memory buffer\n" , i); -RTE_LOG (INFO ,APP ,"flow %u lcoreid %u sched+write port %hu\n" , - i, lcore_id, wt_confs[i]->tx_port); +RTE_LOG (INFO ,APP ,"flow %u lcoreid %u sched+write " +"port %" PRIu8"\n" , + i, lcore_id, wt_confs[i]->tx_port); }app_mixed_thread (wt_confs);
@@ -153,8 +155,9 @@ app_main_loop(__attribute__((unused))void *dummy)if (tx_confs[i]->m_table ==NULL )rte_panic ("flow %u unable to allocate memory buffer\n" , i); -RTE_LOG (INFO ,APP ,"flow %u lcoreid %u writing port %hu\n" , - i, lcore_id, tx_confs[i]->tx_port); +RTE_LOG (INFO ,APP ,"flow %u lcoreid %u " +"writing port %" PRIu8"\n" , + i, lcore_id, tx_confs[i]->tx_port); }app_tx_thread (tx_confs);
@@ -183,18 +186,19 @@ app_stat(void)struct flow_conf *flow = &qos_conf[i];rte_eth_stats_get (flow->rx_port, &stats); -printf ("\nRX port %hu: rx: %" PRIu64" err: %" PRIu64" no_mbuf: %" PRIu64"\n" , - flow->rx_port, - stats.ipackets - rx_stats[i].ipackets, - stats.ierrors - rx_stats[i].ierrors, - stats.rx_nombuf - rx_stats[i].rx_nombuf); +printf ("\nRX port %" PRIu8": rx: %" PRIu64" err: %" PRIu64 +" no_mbuf: %" PRIu64"\n" , + flow->rx_port, + stats.ipackets - rx_stats[i].ipackets, + stats.ierrors - rx_stats[i].ierrors, + stats.rx_nombuf - rx_stats[i].rx_nombuf);memcpy (&rx_stats[i], &stats,sizeof (stats));rte_eth_stats_get (flow->tx_port, &stats); -printf ("TX port %hu: tx: %" PRIu64" err: %" PRIu64"\n" , - flow->tx_port, - stats.opackets - tx_stats[i].opackets, - stats.oerrors - tx_stats[i].oerrors); +printf ("TX port %" PRIu8": tx: %" PRIu64" err: %" PRIu64"\n" , + flow->tx_port, + stats.opackets - tx_stats[i].opackets, + stats.oerrors - tx_stats[i].oerrors);memcpy (&tx_stats[i], &stats,sizeof (stats));//printf("MP = %d\n", rte_mempool_count(conf->app_pktmbuf_pool));
lib/librte_cmdline/cmdline.h +2 -1
@@ -79,7 +79,8 @@ struct cmdline {struct cmdline *cmdline_new (cmdline_parse_ctx_t *ctx,const char *prompt,int s_in,int s_out);void cmdline_set_prompt (struct cmdline *cl,const char *prompt);void cmdline_free (struct cmdline *cl); -void cmdline_printf (const struct cmdline *cl,const char *fmt, ...); +void cmdline_printf (const struct cmdline *cl,const char *fmt, ...) + __attribute__((format (printf,2 ,3 )));int cmdline_in (struct cmdline *cl,const char *buf,int size);int cmdline_write_char (struct rdline *rdl,char c);void cmdline_interact (struct cmdline *cl);
lib/librte_eal/common/include/rte_log.h +2 -1
@@ -258,7 +258,8 @@ int rte_log(uint32_t level, uint32_t logtype, const char *format, ...)* - 0: Success. * - Negative on error. */ -int rte_vlog (uint32_t level,uint32_t logtype,const char *format,va_list ap); +int rte_vlog (uint32_t level,uint32_t logtype,const char *format,va_list ap) + __attribute__((format (printf,3 ,0 )));/** * Generates a log message.
lib/librte_eal/common/include/rte_string_fns.h +2 -1
@@ -68,7 +68,8 @@ extern "C" {* */ int -rte_snprintf (char *buffer,int buflen,const char *format, ...); +rte_snprintf (char *buffer,int buflen,const char *format, ...) + __attribute__((format (printf,3 ,4 )));/** * Takes string "string" parameter and splits it at character "delim"
lib/librte_eal/linuxapp/eal/eal_ivshmem.c +1 -1
@@ -918,7 +918,7 @@ int rte_eal_ivshmem_init(void) ivshmem_config->pci_devs[ivshmem_config->pci_devs_idx].ioremap_addr = res->phys_addr;rte_snprintf (ivshmem_config->pci_devs[ivshmem_config->pci_devs_idx].path,sizeof (ivshmem_config->pci_devs[ivshmem_config->pci_devs_idx].path), - path); +"%s" , path); ivshmem_config->pci_devs_idx++; }
lib/librte_ivshmem/rte_ivshmem.c +2 -2
@@ -777,7 +777,7 @@ rte_ivshmem_metadata_cmdline_generate(char *buffer, unsigned size, const char *n/* add /dev/zero to command-line to fill the space */ tmplen =rte_snprintf (cmdline_ptr, remaining_len,IVSHMEM_QEMU_CMD_FD_FMT ,"/dev/zero" , -0x0 , + (uint64_t )0x0 , zero_size); cmdline_ptr =RTE_PTR_ADD (cmdline_ptr, tmplen);
@@ -792,7 +792,7 @@ rte_ivshmem_metadata_cmdline_generate(char *buffer, unsigned size, const char *n/* add metadata file to the end of command-line */ tmplen =rte_snprintf (cmdline_ptr, remaining_len,IVSHMEM_QEMU_CMD_FD_FMT , cfg_file_path, -0x0 , + (uint64_t )0x0 ,METADATA_SIZE_ALIGNED ); cmdline_ptr =RTE_PTR_ADD (cmdline_ptr, tmplen);
lib/librte_kni/rte_kni.c +4 -4
@@ -158,7 +158,7 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool, } } -rte_snprintf (intf_name,RTE_KNI_NAMESIZE , conf->name); +rte_snprintf (intf_name,RTE_KNI_NAMESIZE ,"%s" , conf->name);rte_snprintf (mz_name,RTE_MEMZONE_NAMESIZE ,"KNI_INFO_%s" , intf_name); mz =kni_memzone_reserve (mz_name,sizeof (struct rte_kni ),SOCKET_ID_ANY ,0 );
@@ -184,8 +184,8 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool, dev_info.group_id = conf->group_id; dev_info.mbuf_size = conf->mbuf_size; -rte_snprintf (ctx->name,RTE_KNI_NAMESIZE , intf_name); -rte_snprintf (dev_info.name,RTE_KNI_NAMESIZE , intf_name); +rte_snprintf (ctx->name,RTE_KNI_NAMESIZE ,"%s" , intf_name); +rte_snprintf (dev_info.name,RTE_KNI_NAMESIZE ,"%s" , intf_name); RTE_LOG(INFO, KNI, "pci: %02x:%02x:%02x \t %02x:%02x\n", dev_info.bus, dev_info.devid, dev_info.function,
@@ -291,7 +291,7 @@ rte_kni_release(struct rte_kni *kni)if (!kni || !kni->in_use)return -1 ; -rte_snprintf (dev_info.name,sizeof (dev_info.name), kni->name); +rte_snprintf (dev_info.name,sizeof (dev_info.name),"%s" , kni->name);if (ioctl (kni_fd,RTE_KNI_IOCTL_RELEASE , &dev_info) <0 ) {RTE_LOG (ERR ,KNI ,"Fail to release kni device\n" );return -1 ;
lib/librte_pmd_i40e/i40e_ethdev.c +1 -1
@@ -1513,7 +1513,7 @@ i40e_allocate_dma_mem_d(__attribute__((unused)) struct i40e_hw *hw,return I40E_ERR_PARAM ; id++; -rte_snprintf (z_name,sizeof (z_name),"i40e_dma_%lu" , id); +rte_snprintf (z_name,sizeof (z_name),"i40e_dma_%" PRIu64, id); mz =rte_memzone_reserve_aligned (z_name, size,0 ,0 , alignment);if (!mz)return I40E_ERR_NO_MEMORY ;
Signature · 1 line
1.9.3
Re: [PATCH v3] EAL: fix usage of printf-like functions
In reply to a message not in the archiveReview
Quoted 1 line · On Sat, 21 Jun 2014 00:34:30 +0100 Bruce Richardson…
(quoted diff) +1
-0+ (int)(strnlen(buf, sizeof(buf)) - sizeof("_config")),
minor nit, paren not needed here
(int)strnlen(buf, sizeof...)
better yet change rte_snprintf() to take a size_t to make it compatiable with snprintf
Re: [PATCH v3] EAL: fix usage of printf-like functions
In reply to a message not in the archiveQuoted 10 lines
-----Original Message-----
From: Stephen Hemminger [mailto:[email protected]]
Sent: Friday, June 20, 2014 4:58 PM
To: Richardson, Bruce
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH v3] EAL: fix usage of printf-like functionsOn Sat, 21 Jun 2014 00:34:30 +0100
Bruce Richardson <[email protected]> wrote:
Quoted 7 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ (int)(strnlen(buf, sizeof(buf)) - sizeof("_config")),minor nit, paren not needed here
(int)strnlen(buf, sizeof...)better yet change
rte_snprintf()to take asize_tto make it compatiable with snprintf
Removing the paren still gives the same error, as the whole expression needs to be int, not just the first part of it.
As for acception size_t vs int, the errors about the type come from the compiler based on its understanding of the printf format, not from anything we have done with rte_snprintf, so I'm not sure how we could change things to make size_t values acceptable here.
/Bruce
Thomas Monjalon
Acked-byRe: [PATCH v3] EAL: fix usage of printf-like functions
In reply to a message not in the archiveQuoted 5 lines
Mark the
rte_log,cmdline_printfandrte_snprintffunctions as being printf-style functions. This causes compilation errors due to mis-matched parameter types, so the parameter types are fixed where appropriate.
Quoted 8 lines
Changes in V2:
* Additional fixes for ivshmem-target compilationChanges in V3:
* additional printf-format fix for i40e driver as pointed out by Pablo De LaraSigned-off-by Bruce Richardson <[email protected]>
Applied for version 1.7.0.
Thanks
Signature · 1 line
Thomas