-
Notifications
You must be signed in to change notification settings - Fork 16
Fix zoneinfo parser #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Arne Redlich <[email protected]>
Spotted by valgrind: ==1728072== 1 errors in context 1 of 2: ==1728072== Syscall param write(buf) points to uninitialised byte(s) ==1728072== at 0x4F4E104: write (write.c:27) ==1728072== by 0x10BE8F: check_permissions (adaptivemmd.c:813) ==1728072== by 0x10CFC4: main (adaptivemmd.c:1361) ==1728072== Address 0x1ffefffdb3 is on thread 1's stack ==1728072== in frame oracle#1, created by check_permissions (adaptivemmd.c:790) ==1728072== Uninitialised value was created by a stack allocation ==1728072== at 0x10BD49: check_permissions (adaptivemmd.c:790) ==1728072== ==1728072== ==1728072== 5 errors in context 2 of 2: ==1728072== Conditional jump or move depends on uninitialised value(s) ==1728072== at 0x4C34D08: strlen (vg_replace_strmem.c:458) ==1728072== by 0x10BE75: check_permissions (adaptivemmd.c:813) ==1728072== by 0x10CFC4: main (adaptivemmd.c:1361) ==1728072== Uninitialised value was created by a stack allocation ==1728072== at 0x10BD49: check_permissions (adaptivemmd.c:790) ==1728072== ==1728072== ERROR SUMMARY: 6 errors from 2 contexts (suppressed: 0 from 0) Signed-off-by: Arne Redlich <[email protected]>
Signed-off-by: Arne Redlich <[email protected]>
Pointed out by clang analyzer. Signed-off-by: Arne Redlich <[email protected]>
$ CC=clang make clang -c -o predict.o predict.c -I. -Wall -g predict.c:223:146: warning: absolute value function 'abs' given an argument of type 'long long' but has parameter of type 'int' which may cause truncation of value [-Wabsolute-value] log_info(2, "Consumption rate on node %d=%ld pages/msec, reclaim rate is %ld pages/msec, Free pages=%ld, low wmark=%ld, high wmark=%ld", nid, abs(m[0]), reclaim_rate, frag_vec[0].free_pages, low_wmark, high_wmark); ^ predict.c:223:146: note: use function 'llabs' instead log_info(2, "Consumption rate on node %d=%ld pages/msec, reclaim rate is %ld pages/msec, Free pages=%ld, low wmark=%ld, high wmark=%ld", nid, abs(m[0]), reclaim_rate, frag_vec[0].free_pages, low_wmark, high_wmark); ^~~ llabs ./predict.h:79:25: note: expanded from macro 'log_info' log_msg(LOG_INFO, __VA_ARGS__) ^ predict.c:227:8: warning: absolute value function 'abs' given an argument of type 'long long' but has parameter of type 'int' which may cause truncation of value [-Wabsolute-value] / abs(m[0]); ^ predict.c:227:8: note: use function 'llabs' instead / abs(m[0]); ^~~ llabs predict.c:247:147: warning: absolute value function 'abs' given an argument of type 'long long' but has parameter of type 'int' which may cause truncation of value [-Wabsolute-value] log_info(3, "Consumption rate on node %d=%ld pages/msec, reclaim rate is %ld pages/msec, Free pages=%ld, low wmark=%ld, high wmark=%ld", nid, abs(m[0]), reclaim_rate, frag_vec[0].free_pages, low_wmark, high_wmark); ^ predict.c:247:147: note: use function 'llabs' instead log_info(3, "Consumption rate on node %d=%ld pages/msec, reclaim rate is %ld pages/msec, Free pages=%ld, low wmark=%ld, high wmark=%ld", nid, abs(m[0]), reclaim_rate, frag_vec[0].free_pages, low_wmark, high_wmark); ^~~ llabs ./predict.h:79:25: note: expanded from macro 'log_info' log_msg(LOG_INFO, __VA_ARGS__) ^ 3 warnings generated. Signed-off-by: Arne Redlich <[email protected]>
Signed-off-by: Arne Redlich <[email protected]>
Annotate log_msg with a format attribute and fix the resulting compiler warnings. Signed-off-by: Arne Redlich <[email protected]>
Pointed out by clang analyzer. While at it, change the return type to void as it always returns 0 / no caller looks at it. Signed-off-by: Arne Redlich <[email protected]>
The parser used to break out of the zone parsing state when encountering a "pagesets" token, which is however not always present - use "protection:" instead. Signed-off-by: Arne Redlich <[email protected]>
Thank you for your pull request and welcome to our community! To contribute, please sign the Oracle Contributor Agreement (OCA).
To sign the OCA, please create an Oracle account and sign the OCA in Oracle's Contributor Agreement Application. When signing the OCA, please provide your GitHub username. After signing the OCA and getting an OCA approval from Oracle, this PR will be automatically updated. |
Please complete the Oracle Contribution Agreement for me to review and merge this pull request. |
Currently the zoneinfo parser leaves the "zone parsing" state encountering a "pagesets" token. This is however not always present, leading to the parser staying in the "zone parsing" state even when the zone and/or node change.
In addition to that, this MR also adds a number of small fixes spotted by compiling the code with clang, clang analyzer and running it under valgrind.