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/filetop.py b/tools/filetop.py
index ccc5a10..238048e 100755
--- a/tools/filetop.py
+++ b/tools/filetop.py
@@ -119,12 +119,14 @@
struct val_t *valp, zero = {};
valp = counts.lookup_or_init(&info, &zero);
- if (is_read) {
- valp->reads++;
- valp->rbytes += count;
- } else {
- valp->writes++;
- valp->wbytes += count;
+ if (valp) {
+ if (is_read) {
+ valp->reads++;
+ valp->rbytes += count;
+ } else {
+ valp->writes++;
+ valp->wbytes += count;
+ }
}
return 0;