diff mbox series

[bpf-next,3/5] samples/bpf: Use NULL for failed to find symbol

Message ID 1524101646-6544-4-git-send-email-leo.yan@linaro.org
State New
Headers show
Series samples/bpf: Minor fixes and cleanup | expand

Commit Message

Leo Yan April 19, 2018, 1:34 a.m. UTC
Function ksym_search() is used to parse address and return the symbol
structure, when the address is out of range for kernel symbols it
returns the symbol structure of kernel '_stext' entry; this introduces
confusion and it misses the chance to intuitively tell the address is
out of range.

This commit changes to use NULL pointer for failed to find symbol, user
functions need to check the pointer is NULL and get to know the address
has no corresponding kernel symbol for it.

Signed-off-by: Leo Yan <leo.yan@linaro.org>

---
 samples/bpf/bpf_load.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

-- 
1.9.1
diff mbox series

Patch

diff --git a/samples/bpf/bpf_load.c b/samples/bpf/bpf_load.c
index c2bf7ca..0c0584f 100644
--- a/samples/bpf/bpf_load.c
+++ b/samples/bpf/bpf_load.c
@@ -726,7 +726,7 @@  struct ksym *ksym_search(long key)
 		/* valid ksym */
 		return &syms[start - 1];
 
-	/* out of range. return _stext */
-	return &syms[0];
+	/* out of range. return NULL */
+	return NULL;
 }