If the util_file_read_l routine in libutil/util_file.c fails to read the file it is passed, it sets a return code of -1. In libdasd/dasd_sys.c, the return code is never checked, and so the variable 'value" has whatever random contents it had when dasd_get_host_access_count is entered.
Either initialize value to zero in dasd_get_host_access_count, or check the return code from util_file_read_l(&value, 10, path to determine if it was successful or not. If not, set value to zero.
Thanks for pointing this out. I've provided a fix for it.
Also, I've found several other occurrences in other tools as well. Will make sure that these get fixed, too.
https://github.com/ibm-s390-linux/s390-tools/blob/3d79a542d4fb4ca35c35e4431b16e6bfef465782/libdasd/dasd_sys.c#L221
If the util_file_read_l routine in libutil/util_file.c fails to read the file it is passed, it sets a return code of -1. In libdasd/dasd_sys.c, the return code is never checked, and so the variable 'value" has whatever random contents it had when dasd_get_host_access_count is entered.
Either initialize value to zero in dasd_get_host_access_count, or check the return code from util_file_read_l(&value, 10, path to determine if it was successful or not. If not, set value to zero.