From e4ad6267f4d385a14fb7e0d466f062bd29ee3ae7 Mon Sep 17 00:00:00 2001 From: Sergey Nikitin Date: Fri, 1 Dec 2023 21:20:51 +0300 Subject: [PATCH] issue #180: fix objtool warning by removing useless function __oo_shmbuf_ptr2off() triggers objtool warning: "__oo_shmbuf_ptr2off() is missing a __noreturn annotation". The function's only purpose now is to crash with ci_assert(0). There's no reason to keep it. The patch moves the assertion to the caller (oo_shmbuf_ptr2off) and removes __oo_shmbuf_ptr2off(). Signed-off-by: Sergey Nikitin --- src/driver/linux_onload/oo_shmbuf.c | 24 ------------------------ src/include/onload/oo_shmbuf.h | 5 +++-- 2 files changed, 3 insertions(+), 26 deletions(-) diff --git a/src/driver/linux_onload/oo_shmbuf.c b/src/driver/linux_onload/oo_shmbuf.c index 5d40584fa..9c1ed5d9e 100644 --- a/src/driver/linux_onload/oo_shmbuf.c +++ b/src/driver/linux_onload/oo_shmbuf.c @@ -70,30 +70,6 @@ int oo_shmbuf_add(struct oo_shmbuf* sh) return i; } -unsigned long __oo_shmbuf_ptr2off(const struct oo_shmbuf* sh, char* ptr) -{ - int i; - unsigned long off; - - /* Fast path is handled at oo_shmbuf_ptr2off(). - * This function is for slow path only. - */ - off = ptr - oo_shmbuf_idx2ptr(sh, 0); - ci_assert(off < 0 || off >= oo_shmbuf_chunk_size(sh) * sh->init_num); - - /* We'd better never hit this path! */ - ci_assert(0); - - for(i = sh->init_num; i < sh->num; i++) { - off = ptr - oo_shmbuf_idx2ptr(sh, i); - - if( off >= 0 && off < oo_shmbuf_chunk_size(sh) ) - return (i << sh->order << PAGE_SHIFT) + off; - } - ci_assert(0); - return -1; -} - int oo_shmbuf_fault(struct oo_shmbuf* sh, struct vm_area_struct* vma, unsigned long off) { diff --git a/src/include/onload/oo_shmbuf.h b/src/include/onload/oo_shmbuf.h index 69856bfc0..3a26ad677 100644 --- a/src/include/onload/oo_shmbuf.h +++ b/src/include/onload/oo_shmbuf.h @@ -49,7 +49,6 @@ oo_shmbuf_off2ptr(const struct oo_shmbuf* sh, unsigned long off) (off & ((1UL << sh->order << PAGE_SHIFT) - 1)); } -extern unsigned long __oo_shmbuf_ptr2off(const struct oo_shmbuf* sh, char* ptr); static inline unsigned long oo_shmbuf_ptr2off(const struct oo_shmbuf* sh, char* ptr) { @@ -61,7 +60,9 @@ oo_shmbuf_ptr2off(const struct oo_shmbuf* sh, char* ptr) return off; /* Slow path: find the pointer in non-continuous chunks */ - return __oo_shmbuf_ptr2off(sh, ptr); + /* We'd better never hit this path! */ + ci_assert(0); + return -1; } static inline long oo_shmbuf_size(struct oo_shmbuf* sh)