Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue: Fix compilation with clang #1051

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,9 @@ show_section_title "Check for functions, types and structures"
#
AC_CHECK_FUNCS(__read_chk __recv_chk __recvfrom_chk __poll_chk __ppoll_chk)

# Check for gettid(). The wrapper appeared in glibc-2.30
AC_CHECK_FUNCS(gettid)

AC_MSG_CHECKING([for SOF_TIMESTAMPING_SOFTWARE support])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <linux/net_tstamp.h>
Expand Down
1 change: 1 addition & 0 deletions src/state_machine/sm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ BULLSEYE_EXCLUDE_BLOCK_END
}

sm_logdbg("SM full table processing done. Allocated memory size of %d bytes", sm_table_entries_size);
(void)sm_table_entries_size; // Suppress --enable-opt-log=high warning
return 0;
}

Expand Down
2 changes: 2 additions & 0 deletions src/vlogger/vlogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,12 @@ namespace log_level
}
}

#ifndef HAVE_GETTID
pid_t gettid(void)
{
return syscall(__NR_gettid);
}
#endif

#if _BullseyeCoverage
#pragma BullseyeCoverage off
Expand Down
2 changes: 2 additions & 0 deletions src/vlogger/vlogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,9 @@ extern vma_log_cb_t g_vlogger_cb;
#define vlog_func_all_enter() vlog_printf(VLOG_FINER,"ENTER %s\n", __PRETTY_FUNCTION__);
#define vlog_func_all_exit() vlog_printf(VLOG_FINER,"EXIT %s\n",__PRETTY_FUNCTION__);

#ifndef HAVE_GETTID
pid_t gettid(void); // Check vlogger.cpp for implementation
#endif

void printf_backtrace(void);

Expand Down
1 change: 1 addition & 0 deletions src/vma/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ libvma_la_SOURCES := \
sock/sockinfo_tcp.h \
sock/sockinfo_udp.h \
sock/sock-redirect.h \
sock/sock-redirect-internal.h \
\
util/chunk_list.h \
util/hash_map.h \
Expand Down
1 change: 1 addition & 0 deletions src/vma/dev/dm_mgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ bool dm_mgr::copy_data(struct mlx5_wqe_data_seg* seg, uint8_t* src, uint32_t len
dev_mem_oob:
dm_logfunc("Send OOB! Buffer[%p] length[%d] length_aligned_8[%d] continuous_left[%zu] head[%zu] used[%zu]",
buff, length, length_aligned_8, continuous_left, m_head, m_used);
NOT_IN_USE(continuous_left); // Suppress dead assignment warning

m_p_ring_stat->simple.n_tx_dev_mem_oob++;

Expand Down
1 change: 1 addition & 0 deletions src/vma/dev/qp_mgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ void qp_mgr::release_rx_buffers()
}
m_last_posted_rx_wr_id = 0; // Clear the posted WR_ID flag, we just clear the entire RQ
qp_logdbg("draining completed with a total of %d wce's on rx cq_mgr", total_ret);
NOT_IN_USE(total_ret); // Suppress --enable-opt-log=high warning
}

void qp_mgr::release_tx_buffers()
Expand Down
3 changes: 1 addition & 2 deletions src/vma/dev/ring_bond.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -919,9 +919,8 @@ void ring_bond_eth::slave_create(int if_index)
void ring_bond_ib::slave_create(int if_index)
{
ring_slave *cur_slave;
ring_simple *cur_simple;

cur_slave = cur_simple = new ring_ib(if_index, this);
cur_slave = new ring_ib(if_index, this);
if (cur_slave == NULL) {
ring_logpanic("Error creating bond ring: memory allocation error");
}
Expand Down
1 change: 1 addition & 0 deletions src/vma/dev/ring_simple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,7 @@ int ring_simple::put_tx_buffers(mem_buf_desc_t* buff_list)
buff_list = next;
}
ring_logfunc("buf_list: %p count: %d freed: %d\n", buff_list, count, freed);
NOT_IN_USE(freed); // Suppress unused-but-set-variable warning

return_to_global_pool();

Expand Down
4 changes: 1 addition & 3 deletions src/vma/dev/ring_tap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -515,8 +515,6 @@ void ring_tap::mem_buf_desc_return_single_to_owner_tx(mem_buf_desc_t* p_mem_buf_
{
auto_unlocker lock(m_lock_ring_tx);

int count = 0;

if (likely(p_mem_buf_desc)) {
//potential race, ref is protected here by ring_tx lock, and in dst_entry_tcp & sockinfo_tcp by tcp lock
if (likely(p_mem_buf_desc->lwip_pbuf.pbuf.ref))
Expand All @@ -528,7 +526,6 @@ void ring_tap::mem_buf_desc_return_single_to_owner_tx(mem_buf_desc_t* p_mem_buf_
p_mem_buf_desc->p_next_desc = NULL;
free_lwip_pbuf(&p_mem_buf_desc->lwip_pbuf);
m_tx_pool.push_back(p_mem_buf_desc);
count++;
}
}

Expand Down Expand Up @@ -568,6 +565,7 @@ int ring_tap::mem_buf_tx_release(mem_buf_desc_t* buff_list, bool b_accounting, b
buff_list = next;
}
ring_logfunc("buf_list: %p count: %d freed: %d\n", buff_list, count, freed);
NOT_IN_USE(freed); // Suppress unused-but-set-variable warning

return_to_global_pool();

Expand Down
1 change: 1 addition & 0 deletions src/vma/event/event_handler_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ void event_handler_manager::priv_prepare_ibverbs_async_event_queue(event_handler
cnt++;
}
evh_logdbg("Emptied %d Events", cnt);
NOT_IN_USE(cnt); // Suppress --enable-opt-log=high warning
}

void event_handler_manager::priv_register_ibverbs_events(ibverbs_reg_info_t& info)
Expand Down
2 changes: 1 addition & 1 deletion src/vma/ib/base/verbs_extra.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ typedef struct {
#ifdef DEFINED_IBV_QP_SUPPORT_BURST
#define vma_ibv_init_burst_attr(qp_attr, rate_limit) { qp_attr.max_burst_sz = rate_limit.max_burst_sz; qp_attr.typical_pkt_sz = rate_limit.typical_pkt_sz; }
typedef struct ibv_qp_rate_limit_attr vma_ibv_rate_limit_attr;
#define vma_ibv_modify_qp_rate_limit(qp, attr, mask) ibv_modify_qp_rate_limit(qp, attr)
#define vma_ibv_modify_qp_rate_limit(qp, attr, mask) ({ NOT_IN_USE(mask); ibv_modify_qp_rate_limit(qp, attr); })
#define vma_ibv_init_qps_attr(qp_attr) { NOT_IN_USE(qp_attr); }
#else
typedef vma_ibv_qp_attr vma_ibv_rate_limit_attr;
Expand Down
1 change: 1 addition & 0 deletions src/vma/iomux/io_mux_call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ void io_mux_call::polling_loops()
}

__if_dbg("2nd scenario exit (loop %d, elapsed %d)", poll_counter, m_elapsed.tv_usec);
NOT_IN_USE(poll_counter); // Suppress unused-but-set-variable warning
}

void io_mux_call::blocking_loops()
Expand Down
79 changes: 79 additions & 0 deletions src/vma/sock/sock-redirect-internal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* Copyright (c) 2001-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU
* General Public License (GPL) Version 2, available from the file
* COPYING in the main directory of this source tree, or the
* BSD license below:
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
*
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

#ifndef SOCK_REDIRECT_INTERNAL_H
#define SOCK_REDIRECT_INTERNAL_H

#include "config.h"

/*
* Workaround for clang compilation error with fortified wrapper redefinition.
*/
#ifdef __clang__
#ifdef HAVE___READ_CHK
#define read read_unused
#endif
#ifdef HAVE___RECV_CHK
#define recv recv_unused
#endif
#ifdef HAVE___RECVFROM_CHK
#define recvfrom recvfrom_unused
#endif
#ifdef HAVE___POLL_CHK
#define poll poll_unused
#endif
#ifdef HAVE___PPOLL_CHK
#define ppoll ppoll_unused
#endif
#endif /* __clang__ */
#include <unistd.h>
#include <sys/socket.h>
#include <poll.h>
#ifdef __clang__
#ifdef HAVE___READ_CHK
#undef read
#endif
#ifdef HAVE___RECV_CHK
#undef recv
#endif
#ifdef HAVE___RECVFROM_CHK
#undef recvfrom
#endif
#ifdef HAVE___POLL_CHK
#undef poll
#endif
#ifdef HAVE___PPOLL_CHK
#undef ppoll
#endif
#endif /* __clang__ */

#endif /* SOCK_REDIRECT_INTERNAL_H */
2 changes: 2 additions & 0 deletions src/vma/sock/sock-redirect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
*/


// sock-redirect-internal.h must be first
#include "sock-redirect-internal.h"
#include "sock-redirect.h"

#include <sys/time.h>
Expand Down
1 change: 1 addition & 0 deletions src/vma/sock/sockinfo_udp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1520,6 +1520,7 @@ int sockinfo_udp::rx_request_notification(uint64_t poll_sn)
m_rx_ring_map_lock.unlock();

si_udp_logfunc("armed or busy %d ring(s) and %d ring are pending processing", ring_armed_count, ring_ready_count);
NOT_IN_USE(ring_armed_count); // Suppress unused-but-set-variable warning
return ring_ready_count;
}

Expand Down
18 changes: 12 additions & 6 deletions tools/daemon/tc.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,10 @@ int tc_add_filter_link(tc_t tc, int ifindex, int prio, int ht, int id, uint32_t
uint32_t opt_ht = HANDLE_SET(ht, 0, 0);
struct rtattr *opts = NULL;
struct {
struct tc_u32_sel sel;
struct tc_u32_key keys[5];
union {
struct tc_u32_sel sel;
uint8_t pad[sizeof(struct tc_u32_sel) + sizeof(struct tc_u32_key) * 5U];
};
} opt_sel;

tc_req(tc, ifindex, RTM_NEWTFILTER,
Expand Down Expand Up @@ -357,8 +359,10 @@ int tc_add_filter_tap2dev(tc_t tc, int ifindex, int prio, int id, uint32_t ip, i
uint32_t opt_ht = HANDLE_SET(0x800, 0, 0);
struct rtattr *opts = NULL;
struct {
struct tc_u32_sel sel;
struct tc_u32_key keys[5];
union {
struct tc_u32_sel sel;
uint8_t pad[sizeof(struct tc_u32_sel) + sizeof(struct tc_u32_key) * 5U];
};
} opt_sel;

tc_req(tc, ifindex, RTM_NEWTFILTER,
Expand Down Expand Up @@ -479,8 +483,10 @@ int tc_add_filter_dev2tap(tc_t tc, int ifindex, int prio, int ht, int bkt, int i
uint32_t opt_ht = HANDLE_SET(ht, bkt, 0);
struct rtattr *opts = NULL;
struct {
struct tc_u32_sel sel;
struct tc_u32_key keys[10];
union {
struct tc_u32_sel sel;
uint8_t pad[sizeof(struct tc_u32_sel) + sizeof(struct tc_u32_key) * 10U];
};
} opt_sel;

tc_req(tc, ifindex, RTM_NEWTFILTER,
Expand Down