Fixes #2518 -- weird behaviour of lookup_or_init (#2520)
* Allow lookup_or_init to return NULL (rather than just returning from the current function)
* Fixed a couple of bad edits found when running tests. Also fixed a bug in the
test runner. Also fixed a bug in libbcc where the python signature did not match
the actual implementation.
diff --git a/tools/lib/ustat.py b/tools/lib/ustat.py
index 1edc985..bd5b98b 100755
--- a/tools/lib/ustat.py
+++ b/tools/lib/ustat.py
@@ -94,7 +94,9 @@
u64 *valp, zero = 0;
u32 tgid = bpf_get_current_pid_tgid() >> 32;
valp = %s_%s_counts.lookup_or_init(&tgid, &zero);
- ++(*valp);
+ if (valp) {
+ ++(*valp);
+ }
return 0;
}
"""