-
Type: Bug
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Storage Engines
-
StorEng - Defined Pipeline
This ticket collects some seemingly unused ret values that can't be automatically detected by compiler or standard static analysis.
It's not required to do all of them within this ticket. If any of these cases takes more than 5-10 minutes to investigate, it should be split into a separate ticket.
- src/reconcile/rec_track.c:400
- src/txn/txn_ckpt.c:1363:46
- src/txn/txn_ckpt.c:1423:11
- src/txn/txn_ckpt.c:1488 - probably fine
- src/txn/txn_recover.c:1178 subsequent WT_ERR overwrites the error code.
- __wt_txn_rollback builds up the return code and returns it but it never alters its behavior if there's a failure.
- __curjoin_close builds up the return code and returns it but it never alters its behavior if there's a failure.
- src/include/btree_inline.h:2019 - probably fine
- src/meta/meta_turtle.c:441 should probably be "ignore".
- src/block_cache/block_cache.c:636 - this probably should be converted to "panic" or "ignore"
- src/utilities/util_main.c:345:5 ret can be overwritten later and ignored.
- These two get overwritten by subsequent WT_ERR:
- These two get overwritten just after and should be replaced with "ignore":
For reference: this script is used for detection:
#!/bin/bash perl -nE ' # Read entire file do { local $/=undef; $_=<>; }; # Iterate through all assignments to `ret` plus following 15 lines of code afterwards while (/\n.*\b(?:(?:ret\s+=\s+(?!\d|WT_))|WT_TRET|WT_WINCALL_RETRY)(?:.*\n){15}/g) { # Save match $x = $&; # Calculate current matched position my $pos = pos()-length($x); # Set the next position to search from pos() = $pos+1; # Calculate line and offset $line = 3+(()=substr($_,0,$pos)=~/\n/g); $off = $x =~ /^\n.*\bret = / ? ":".(length($&)-6) : ""; # Skip if the assignment is within a conditional expression next if $x =~ /^\n.*\b(?:while|if|switch|for).*?\bret = /; # Cut the useful portion of code after assignment: # Either until the end of the current function of until the next assignment. ($m = $x) =~ s/^\n.*?\bret = //; $m =~ s/\n[}]\n.*$//s; $next_ret = $m =~ s/\bret = .*$//s; # Skip if `ret` is referenced or there is a goto to error handling. next if $m =~ /\b(?:ret|goto (?:err|done))\b/; # Skip if its a conditional branch and theres an assignment coming next - we will check the next one next. next if $next_ret && $m =~ / ^ [^{}]+ (?: (?: (?: [}] \s+ )? \b else \b (?: \s+ [{] )? ) | (?: \b (?: case | default ) \b ) ) [^{}]+ $ /xs; # Output the line in the compiler format. say "$ARGV:$line$off:".($x =~ s/(?<=.)\n.*$//sr =~ s/^\n//r); } ' `find src -name \*.[ch]`