From: Chuck Lever Date: Tue, 17 Feb 2009 20:19:58 +0000 (-0500) Subject: text-based mount command: fix return value from po_rightmost() X-Git-Tag: nfs-utils-1-1-5~25 X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=commitdiff_plain;h=e7ec5e745e851ad10c56d579463ee7e1b85c9c21;hp=e7ec5e745e851ad10c56d579463ee7e1b85c9c21 text-based mount command: fix return value from po_rightmost() Recently commit 0dcb83a8 changed the po_rightmost() function to distinguish among several possible mount options by taking a table containing the alternatives, and returning the table index of the entry which is rightmost in the mount option string. If it didn't find any mount option that matches an entry from the passed-in table, it returned zero. This was the same behavior it had before, when it only checked for two options at a time. It returned PO_NEITHER_FOUND, which was zero. Since this is C, however, zero also happens to be a valid index into the passed-in array of options. Modify the po_rightmost() function to return -1 if the entry wasn't found, and fix up the callers to look for a C-style array index that starts at zero. Thanks to Steve Dickson for troubleshooting the problem. His solution was merely to bump the return value, as callers already expected an ordinal index instead of a C-style index. I prefer this equivalent but slightly more extensive change because it makes the behavior of po_rightmost() more closely match how humans understand C arrays to work. Let's address some of the confusion that caused this bug, as well as fixing the run-time behavior. Signed-off-by: Chuck Lever Signed-off-by: Steve Dickson ---