[PATCH 1/2] Fix control reaches end of non-void function in elflink.c

3 views
Skip to first unread message

er...@munsonfam.org

unread,
Aug 18, 2019, 9:42:00 PM8/18/19
to libhug...@googlegroups.com, Eric B Munson
From: Eric B Munson <er...@munsonfam.org>

The hugetlb_slice_[start|end] functions were arranged in such a way that
they would hit the end of the function wihtout returning a value on non
PPC architectures. The new function should have the same output but
will guarantee a return value.

Signed-off-by: Eric B Munson <er...@munsonfam.org>
---
elflink.c | 40 ++++++++++++++++++++--------------------
1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/elflink.c b/elflink.c
index a6bd44c..ce2ed24 100644
--- a/elflink.c
+++ b/elflink.c
@@ -569,36 +569,36 @@ bail2:
*/
static unsigned long hugetlb_slice_start(unsigned long addr)
{
- if (!arch_has_slice_support()) {
- return ALIGN_DOWN(addr, gethugepagesize());
- }
-
+ if (arch_has_slice_support()) {
#if defined(__powerpc64__)
- if (addr < SLICE_LOW_TOP)
- return ALIGN_DOWN(addr, SLICE_LOW_SIZE);
- else if (addr < SLICE_HIGH_SIZE)
- return SLICE_LOW_TOP;
- else
- return ALIGN_DOWN(addr, SLICE_HIGH_SIZE);
+ if (addr < SLICE_LOW_TOP)
+ return ALIGN_DOWN(addr, SLICE_LOW_SIZE);
+ else if (addr < SLICE_HIGH_SIZE)
+ return SLICE_LOW_TOP;
+ else
+ return ALIGN_DOWN(addr, SLICE_HIGH_SIZE);
#elif defined(__powerpc__) && !defined(PPC_NO_SEGMENTS)
- return ALIGN_DOWN(addr, SLICE_LOW_SIZE);
+ return ALIGN_DOWN(addr, SLICE_LOW_SIZE);
#endif
+ }
+
+ return ALIGN_DOWN(addr, gethugepagesize());
}

static unsigned long hugetlb_slice_end(unsigned long addr)
{
- if (!arch_has_slice_support()) {
- return ALIGN_UP(addr, gethugepagesize()) - 1;
- }
-
+ if (arch_has_slice_support()) {
#if defined(__powerpc64__)
- if (addr < SLICE_LOW_TOP)
- return ALIGN_UP(addr, SLICE_LOW_SIZE) - 1;
- else
- return ALIGN_UP(addr, SLICE_HIGH_SIZE) - 1;
+ if (addr < SLICE_LOW_TOP)
+ return ALIGN_UP(addr, SLICE_LOW_SIZE) - 1;
+ else
+ return ALIGN_UP(addr, SLICE_HIGH_SIZE) - 1;
#elif defined(__powerpc__) && !defined(PPC_NO_SEGMENTS)
- return ALIGN_UP(addr, SLICE_LOW_SIZE) - 1;
+ return ALIGN_UP(addr, SLICE_LOW_SIZE) - 1;
#endif
+ }
+
+ return ALIGN_UP(addr, gethugepagesize()) - 1;
}

static unsigned long hugetlb_next_slice_start(unsigned long addr)
--
2.20.1

Eric B Munson

unread,
Aug 19, 2019, 4:56:34 PM8/19/19
to libhug...@googlegroups.com
On Sun, 18 Aug 2019, er...@munsonfam.org wrote:

> From: Eric B Munson <er...@munsonfam.org>
>
> The hugetlb_slice_[start|end] functions were arranged in such a way that
> they would hit the end of the function wihtout returning a value on non
> PPC architectures. The new function should have the same output but
> will guarantee a return value.
>
> Signed-off-by: Eric B Munson <er...@munsonfam.org>

Applied, thanks
Reply all
Reply to author
Forward
0 new messages