Skip to content

Commit 5eaace1

Browse files
rghaddabcarlescufi
authored andcommitted
ipc_service: static_vrings: fix num_desc return value
currently when no enough memory is found a (1 << (-1)) value is returned instead of 0. Fix this by returning 0 and simplify log2 computation Signed-off-by: Riadh Ghaddab <[email protected]>
1 parent cb69a0a commit 5eaace1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

subsys/ipc/ipc_service/backends/ipc_rpmsg_static_vrings.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,5 +163,6 @@ static inline unsigned int optimal_num_desc(size_t mem_size, unsigned int buf_si
163163
num_desc++;
164164
}
165165

166-
return (1 << (find_msb_set(--num_desc) - 1));
166+
/* if num_desc == 1 there is not enough memory */
167+
return (--num_desc == 0) ? 0 : (1 << LOG2(num_desc));
167168
}

0 commit comments

Comments
 (0)