mirror of
https://git.openafs.org/openafs.git
synced 2025-01-18 15:00:12 +00:00
DARWIN: Use NSUInteger for indexGreaterThanIndex return value
The indexGreaterThanIndex function returns the closest index from the index set that is greater than a specified index. This function is typically used in a loop to iterate through a list of items until it returns NSNotFound, indicating the end of the list. In AFSCommanderPref.m, the following pattern is being used: int index = 0; do { ... } while((index = [... indexGreaterThanIndex:index]) != NSNotFound); The issue arises because indexGreaterThanIndex returns an NSUInteger, while the loop uses an int for index. If NSNotFound is cast to an int, it becomes -1, causing the loop to never terminate and leading to a crash. To fix this problem, change the type of index from int to NSUInteger to ensure proper comparison and termination of the loop when NSNotFound is returned. Change-Id: I0b8b38d201b500c2d6d7778f0132ce17f7c04ac8 Reviewed-on: https://gerrit.openafs.org/15961 Reviewed-by: Michael Meffie <mmeffie@sinenomine.net> Reviewed-by: Cheyenne Wills <cwills@sinenomine.net> Reviewed-by: Mark Vitale <mvitale@sinenomine.net> Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Andrew Deason <adeason@sinenomine.net>
This commit is contained in:
parent
e45d0bd1e1
commit
d76df7cb24
@ -569,7 +569,7 @@
|
||||
|
||||
case REMOVE_CELL_CONTROL_TAG:
|
||||
{
|
||||
int index = 0;
|
||||
NSUInteger index;
|
||||
NSIndexSet *selectedIndex = [(NSTableView*)cellList selectedRowIndexes];
|
||||
if( [selectedIndex count] > 0) {
|
||||
index = [selectedIndex firstIndex];
|
||||
@ -697,7 +697,7 @@
|
||||
// -------------------------------------------------------------------------------
|
||||
- (IBAction) unlog:(id) sender
|
||||
{
|
||||
int index = -1;
|
||||
NSUInteger index;
|
||||
NSIndexSet *selectedIndex = [tokensTable selectedRowIndexes];
|
||||
if( [selectedIndex count] > 0) {
|
||||
index = [selectedIndex firstIndex];
|
||||
@ -941,14 +941,14 @@
|
||||
// -------------------------------------------------------------------------------
|
||||
- (IBAction) removeLink:(id) sender {
|
||||
if(!linkConfiguration) return;
|
||||
int index = 0;
|
||||
NSUInteger index;
|
||||
NSArray *keys = [linkConfiguration allKeys];
|
||||
NSIndexSet *linkToRemove = [tableViewLink selectedRowIndexes];
|
||||
if( [linkToRemove count] > 0) {
|
||||
index = [linkToRemove firstIndex];
|
||||
do {
|
||||
[linkConfiguration removeObjectForKey:[keys objectAtIndex:index]];
|
||||
} while ((index = [linkToRemove indexGreaterThanIndex:index]) != -1);
|
||||
} while ((index = [linkToRemove indexGreaterThanIndex:index]) != NSNotFound);
|
||||
}
|
||||
|
||||
//write the new configuration
|
||||
|
Loading…
Reference in New Issue
Block a user