Skip to content

Commit

Permalink
issue Xilinx-CNS#180: fix objtool warning by removing useless function
Browse files Browse the repository at this point in the history
__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 <[email protected]>
  • Loading branch information
okt-sergeyn committed Dec 1, 2023
1 parent 9f936e4 commit e4ad626
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 26 deletions.
24 changes: 0 additions & 24 deletions src/driver/linux_onload/oo_shmbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
5 changes: 3 additions & 2 deletions src/include/onload/oo_shmbuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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)
Expand Down

0 comments on commit e4ad626

Please sign in to comment.