Skip to content

Commit a38e374

Browse files
authored
Merge pull request #1457 from ychin/fix-macvim-warnings
Fix misc MacVim warnings and treat warnings as errors in CI
2 parents 0f293b5 + b6f7d7d commit a38e374

30 files changed

Lines changed: 264 additions & 269 deletions

.github/workflows/ci-macvim.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ jobs:
188188
189189
./configure "${CONFOPT[@]}" --enable-fail-if-missing
190190
191-
sed -i.bak -f ci/config.mk.sed -f ci/config.mk.clang.sed src/auto/config.mk
191+
sed -i.bak -f ci/config.mk.sed -f ci/config.mk.clang.sed -f ci/config.mk.xcode.sed src/auto/config.mk
192192
if clang --version | grep -qs '^Apple clang version \(1[3-9]\|[2-9]\d\)\.'; then
193193
sed -i.bak -f ci/config.mk.clang-12.sed src/auto/config.mk
194194
fi

ci/config.mk.xcode.sed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/^XCODEFLAGS[[:blank:]]*=/s/$/ GCC_TREAT_WARNINGS_AS_ERRORS="YES" GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS="NO"/

src/MacVim/MMAppController.m

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ - (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender
567567

568568
// The user default MMUntitledWindow can be set to control whether an
569569
// untitled window should open on 'Open' and 'Reopen' events.
570-
int untitledWindowFlag = [ud integerForKey:MMUntitledWindowKey];
570+
NSInteger untitledWindowFlag = [ud integerForKey:MMUntitledWindowKey];
571571

572572
BOOL isAppOpenEvent = [desc eventID] == kAEOpenApplication;
573573
if (isAppOpenEvent && (untitledWindowFlag & MMUntitledWindowOnOpen) == 0)
@@ -700,7 +700,7 @@ - (NSApplicationTerminateReply)applicationShouldTerminate:
700700
boolForKey:MMSuppressTerminationAlertKey]) {
701701
// No unmodified buffers, but give a warning if there are multiple
702702
// windows and/or tabs open.
703-
int numWindows = [vimControllers count];
703+
int numWindows = (int)[vimControllers count];
704704
int numTabs = 0;
705705

706706
// Count the number of open tabs
@@ -1065,7 +1065,7 @@ - (void)refreshMainMenu
10651065
[fileMenu removeItemAtIndex:dummyIdx];
10661066

10671067
NSMenu *recentFilesParentMenu = [recentFilesMenuItem menu];
1068-
int idx = [recentFilesParentMenu indexOfItem:recentFilesMenuItem];
1068+
NSInteger idx = [recentFilesParentMenu indexOfItem:recentFilesMenuItem];
10691069
if (idx >= 0) {
10701070
[[recentFilesMenuItem retain] autorelease];
10711071
[recentFilesParentMenu removeItemAtIndex:idx];
@@ -1133,7 +1133,7 @@ - (BOOL)openFiles:(NSArray *)filenames withArguments:(NSDictionary *)args
11331133

11341134
// The meaning of "layout" is defined by the WIN_* defines in main.c.
11351135
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
1136-
int layout = [ud integerForKey:MMOpenLayoutKey];
1136+
NSInteger layout = [ud integerForKey:MMOpenLayoutKey];
11371137
BOOL splitVert = [ud boolForKey:MMVerticalSplitKey];
11381138
BOOL openInCurrentWindow = [ud boolForKey:MMOpenInCurrentWindowKey];
11391139

@@ -1166,7 +1166,7 @@ - (BOOL)openFiles:(NSArray *)filenames withArguments:(NSDictionary *)args
11661166
// selection will be lost when selectionRange is set.
11671167
NSDictionary *args = [NSDictionary dictionaryWithObjectsAndKeys:
11681168
firstFile, @"filename",
1169-
[NSNumber numberWithInt:layout], @"layout",
1169+
[NSNumber numberWithInt:(int)layout], @"layout",
11701170
nil];
11711171
[vc sendMessage:SelectAndFocusOpenedFileMsgID data:[args dictionaryAsData]];
11721172
}
@@ -1188,7 +1188,7 @@ - (BOOL)openFiles:(NSArray *)filenames withArguments:(NSDictionary *)args
11881188
// b) Open any remaining files
11891189
//
11901190

1191-
[arguments setObject:[NSNumber numberWithInt:layout] forKey:@"layout"];
1191+
[arguments setObject:[NSNumber numberWithInt:(int)layout] forKey:@"layout"];
11921192
[arguments setObject:filenames forKey:@"filenames"];
11931193
// (Indicate that files should be opened from now on.)
11941194
[arguments setObject:[NSNumber numberWithBool:NO] forKey:@"dontOpen"];
@@ -1202,7 +1202,7 @@ - (BOOL)openFiles:(NSArray *)filenames withArguments:(NSDictionary *)args
12021202
}
12031203

12041204
BOOL openOk = YES;
1205-
int numFiles = [filenames count];
1205+
int numFiles = (int)[filenames count];
12061206
if (MMLayoutWindows == layout && numFiles > 1) {
12071207
// Open one file at a time in a new window, but don't open too many at
12081208
// once (at most cap+1 windows will open). If the user has increased
@@ -1246,7 +1246,7 @@ - (BOOL)openFiles:(NSArray *)filenames withArguments:(NSDictionary *)args
12461246

12471247
- (void)refreshAllAppearances
12481248
{
1249-
unsigned count = [vimControllers count];
1249+
const NSUInteger count = [vimControllers count];
12501250
for (unsigned i = 0; i < count; ++i) {
12511251
MMVimController *vc = [vimControllers objectAtIndex:i];
12521252
[vc.windowController refreshApperanceMode];
@@ -1256,7 +1256,7 @@ - (void)refreshAllAppearances
12561256
/// Refresh all Vim text views' fonts.
12571257
- (void)refreshAllFonts
12581258
{
1259-
unsigned count = [vimControllers count];
1259+
const NSUInteger count = [vimControllers count];
12601260
for (unsigned i = 0; i < count; ++i) {
12611261
MMVimController *vc = [vimControllers objectAtIndex:i];
12621262
[vc.windowController refreshFonts];
@@ -1267,7 +1267,7 @@ - (void)refreshAllFonts
12671267
/// and resize the windows to match the constraints.
12681268
- (void)refreshAllResizeConstraints
12691269
{
1270-
const unsigned count = [vimControllers count];
1270+
const NSUInteger count = [vimControllers count];
12711271
for (unsigned i = 0; i < count; ++i) {
12721272
MMVimController *vc = [vimControllers objectAtIndex:i];
12731273
[vc.windowController updateResizeConstraints:YES];
@@ -1278,7 +1278,7 @@ - (void)refreshAllResizeConstraints
12781278
/// cmdline alignment properties to make sure they are pinned properly.
12791279
- (void)refreshAllTextViews
12801280
{
1281-
unsigned count = [vimControllers count];
1281+
const NSUInteger count = [vimControllers count];
12821282
for (unsigned i = 0; i < count; ++i) {
12831283
MMVimController *vc = [vimControllers objectAtIndex:i];
12841284
[vc.windowController.vimView.textView updateCmdlineRow];
@@ -1408,7 +1408,7 @@ - (IBAction)selectNextWindow:(id)sender
14081408
{
14091409
ASLogDebug(@"Select next window");
14101410

1411-
unsigned i, count = [vimControllers count];
1411+
NSUInteger i, count = [vimControllers count];
14121412
if (!count) return;
14131413

14141414
NSWindow *keyWindow = [NSApp keyWindow];
@@ -1430,7 +1430,7 @@ - (IBAction)selectPreviousWindow:(id)sender
14301430
{
14311431
ASLogDebug(@"Select previous window");
14321432

1433-
unsigned i, count = [vimControllers count];
1433+
NSUInteger i, count = [vimControllers count];
14341434
if (!count) return;
14351435

14361436
NSWindow *keyWindow = [NSApp keyWindow];
@@ -1542,7 +1542,7 @@ - (IBAction)coreTextButtonClicked:(id)sender
15421542
// any new Vim process will pick up on the changed setting.
15431543
CFPreferencesSetAppValue(
15441544
(CFStringRef)MMRendererKey,
1545-
(CFPropertyListRef)[NSNumber numberWithInt:renderer],
1545+
(CFPropertyListRef)[NSNumber numberWithInt:(int)renderer],
15461546
kCFPreferencesCurrentApplication);
15471547
CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
15481548

@@ -1578,7 +1578,7 @@ - (MMVimController *)keyVimController
15781578
{
15791579
NSWindow *keyWindow = [NSApp keyWindow];
15801580
if (keyWindow) {
1581-
unsigned i, count = [vimControllers count];
1581+
NSUInteger i, count = [vimControllers count];
15821582
for (i = 0; i < count; ++i) {
15831583
MMVimController *vc = [vimControllers objectAtIndex:i];
15841584
if ([[[vc windowController] window] isEqual:keyWindow])
@@ -1660,7 +1660,7 @@ - (NSArray *)serverList
16601660
{
16611661
NSMutableArray *array = [NSMutableArray array];
16621662

1663-
unsigned i, count = [vimControllers count];
1663+
NSUInteger i, count = [vimControllers count];
16641664
for (i = 0; i < count; ++i) {
16651665
MMVimController *controller = [vimControllers objectAtIndex:i];
16661666
if ([controller serverName])
@@ -1931,15 +1931,15 @@ - (MMVimController *)topmostVimController
19311931
NSEnumerator *e = [[NSApp orderedWindows] objectEnumerator];
19321932
id window;
19331933
while ((window = [e nextObject]) && [window isVisible]) {
1934-
unsigned i, count = [vimControllers count];
1934+
NSUInteger i, count = [vimControllers count];
19351935
for (i = 0; i < count; ++i) {
19361936
MMVimController *vc = [vimControllers objectAtIndex:i];
19371937
if ([[[vc windowController] window] isEqual:window])
19381938
return vc;
19391939
}
19401940
}
19411941

1942-
unsigned i, count = [vimControllers count];
1942+
NSUInteger i, count = [vimControllers count];
19431943
for (i = 0; i < count; ++i) {
19441944
MMVimController *vc = [vimControllers objectAtIndex:i];
19451945
if ([[[vc windowController] window] isVisible]) {
@@ -2016,7 +2016,7 @@ - (NSArray *)filterFilesAndNotify:(NSArray *)filenames
20162016

20172017
NSString *firstMissingFile = nil;
20182018
NSMutableArray *files = [NSMutableArray array];
2019-
unsigned i, count = [filenames count];
2019+
NSUInteger i, count = [filenames count];
20202020

20212021
for (i = 0; i < count; ++i) {
20222022
NSString *name = [filenames objectAtIndex:i];
@@ -2076,7 +2076,7 @@ - (NSArray *)filterOpenFiles:(NSArray *)filenames
20762076
@"map([\"%@\"],\"bufloaded(v:val)\")",
20772077
[files componentsJoinedByString:@"\",\""]];
20782078

2079-
unsigned i, count = [vimControllers count];
2079+
NSUInteger i, count = [vimControllers count];
20802080
for (i = 0; i < count && [files count] > 0; ++i) {
20812081
MMVimController *vc = [vimControllers objectAtIndex:i];
20822082

@@ -2428,12 +2428,12 @@ - (int)maxPreloadCacheSize
24282428
{
24292429
// The maximum number of Vim processes to keep in the cache can be
24302430
// controlled via the user default "MMPreloadCacheSize".
2431-
int maxCacheSize = [[NSUserDefaults standardUserDefaults]
2431+
NSInteger maxCacheSize = [[NSUserDefaults standardUserDefaults]
24322432
integerForKey:MMPreloadCacheSizeKey];
24332433
if (maxCacheSize < 0) maxCacheSize = 0;
24342434
else if (maxCacheSize > 10) maxCacheSize = 10;
24352435

2436-
return maxCacheSize;
2436+
return (int)maxCacheSize;
24372437
}
24382438

24392439
- (MMVimController *)takeVimControllerFromCache
@@ -2445,7 +2445,7 @@ - (MMVimController *)takeVimControllerFromCache
24452445
// This method may return nil even though the cache might be non-empty; the
24462446
// caller should handle this by starting a new Vim process.
24472447

2448-
int i, count = [cachedVimControllers count];
2448+
NSUInteger i, count = [cachedVimControllers count];
24492449
if (0 == count) return nil;
24502450

24512451
// Locate the first Vim controller with up-to-date rc-files sourced.
@@ -2461,7 +2461,7 @@ - (MMVimController *)takeVimControllerFromCache
24612461
// Clear out cache entries whose vimrc/gvimrc files were sourced before
24622462
// the latest modification date for those files. This ensures that the
24632463
// latest rc-files are always sourced for new windows.
2464-
[self clearPreloadCacheWithCount:i];
2464+
[self clearPreloadCacheWithCount:(int)i];
24652465
}
24662466

24672467
if ([cachedVimControllers count] == 0) {
@@ -2497,7 +2497,7 @@ - (void)clearPreloadCacheWithCount:(int)count
24972497
return;
24982498

24992499
if (count < 0)
2500-
count = [cachedVimControllers count];
2500+
count = (int)[cachedVimControllers count];
25012501

25022502
// Make sure the preloaded Vim processes get killed or they'll just hang
25032503
// around being useless until MacVim is terminated.
@@ -2618,9 +2618,7 @@ - (void)startWatchingVimDir
26182618
(CFArrayRef)pathsToWatch, kFSEventStreamEventIdSinceNow,
26192619
MMEventStreamLatency, kFSEventStreamCreateFlagNone);
26202620

2621-
FSEventStreamScheduleWithRunLoop(fsEventStream,
2622-
[[NSRunLoop currentRunLoop] getCFRunLoop],
2623-
kCFRunLoopDefaultMode);
2621+
FSEventStreamSetDispatchQueue(fsEventStream, dispatch_get_main_queue());
26242622

26252623
FSEventStreamStart(fsEventStream);
26262624
ASLogDebug(@"Started FS event stream");
@@ -2734,9 +2732,9 @@ - (int)executeInLoginShell:(NSString *)path arguments:(NSArray *)args
27342732

27352733
// Send input to execute to the child process
27362734
[input appendString:@"\n"];
2737-
int bytes = [input lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
2735+
NSUInteger bytes = [input lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
27382736

2739-
if (write(ds[1], [input UTF8String], bytes) != bytes) return -1;
2737+
if (write(ds[1], [input UTF8String], (size_t)bytes) != (ssize_t)bytes) return -1;
27402738
if (close(ds[1]) == -1) return -1;
27412739

27422740
++numChildProcesses;
@@ -2797,7 +2795,7 @@ - (void)processInputQueues:(id)sender
27972795
NSNumber *key;
27982796
while ((key = [e nextObject])) {
27992797
unsigned long ukey = [key unsignedLongValue];
2800-
int i = 0, count = [vimControllers count];
2798+
NSUInteger i = 0, count = [vimControllers count];
28012799
for (i = 0; i < count; ++i) {
28022800
MMVimController *vc = [vimControllers objectAtIndex:i];
28032801
if (ukey == [vc vimControllerId]) {
@@ -2882,7 +2880,7 @@ - (NSDictionary *)convertVimControllerArguments:(NSDictionary *)args
28822880
*cmdline = nil;
28832881

28842882
NSArray *filenames = [args objectForKey:@"filenames"];
2885-
int numFiles = filenames ? [filenames count] : 0;
2883+
NSUInteger numFiles = filenames ? [filenames count] : 0;
28862884
BOOL openFiles = ![[args objectForKey:@"dontOpen"] boolValue];
28872885

28882886
if (numFiles <= 0 || !openFiles)
@@ -3029,7 +3027,7 @@ - (void)removeInputSourceChangedObserver
30293027

30303028
- (void)inputSourceChanged:(NSNotification *)notification
30313029
{
3032-
unsigned i, count = [vimControllers count];
3030+
NSUInteger i, count = [vimControllers count];
30333031
for (i = 0; i < count; ++i) {
30343032
MMVimController *controller = [vimControllers objectAtIndex:i];
30353033
MMWindowController *wc = [controller windowController];

src/MacVim/MMApplication.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ @implementation MMApplication
2121
- (void)sendEvent:(NSEvent *)event
2222
{
2323
NSEventType type = [event type];
24-
unsigned flags = [event modifierFlags];
24+
NSUInteger flags = [event modifierFlags];
2525

2626
// HACK! Intercept 'help' key presses and clear the 'help key flag', else
2727
// Cocoa turns the mouse cursor into a question mark and goes into 'context

src/MacVim/MMBackend.m

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848
static unsigned MMServerMax = 1000;
4949

5050
// TODO: Move to separate file.
51-
static int eventModifierFlagsToVimModMask(int modifierFlags);
52-
static int eventModifierFlagsToVimMouseModMask(int modifierFlags);
51+
static unsigned eventModifierFlagsToVimModMask(unsigned modifierFlags);
52+
static unsigned eventModifierFlagsToVimMouseModMask(unsigned modifierFlags);
5353
static int eventButtonNumberToVimMouseButton(int buttonNumber);
5454

5555
// In gui_macvim.m
@@ -2081,7 +2081,7 @@ - (void)handleInputEvent:(int)msgid data:(NSData *)data
20812081

20822082
int row = *((int*)bytes); bytes += sizeof(int);
20832083
int col = *((int*)bytes); bytes += sizeof(int);
2084-
int flags = *((int*)bytes); bytes += sizeof(int);
2084+
unsigned flags = *((unsigned*)bytes); bytes += sizeof(unsigned);
20852085
float dy = *((float*)bytes); bytes += sizeof(float);
20862086
float dx = *((float*)bytes); bytes += sizeof(float);
20872087

@@ -2122,7 +2122,7 @@ - (void)handleInputEvent:(int)msgid data:(NSData *)data
21222122
int row = *((int*)bytes); bytes += sizeof(int);
21232123
int col = *((int*)bytes); bytes += sizeof(int);
21242124
int button = *((int*)bytes); bytes += sizeof(int);
2125-
int flags = *((int*)bytes); bytes += sizeof(int);
2125+
unsigned flags = *((unsigned*)bytes); bytes += sizeof(unsigned);
21262126
int repeat = *((int*)bytes); bytes += sizeof(int);
21272127

21282128
button = eventButtonNumberToVimMouseButton(button);
@@ -2136,7 +2136,7 @@ - (void)handleInputEvent:(int)msgid data:(NSData *)data
21362136

21372137
int row = *((int*)bytes); bytes += sizeof(int);
21382138
int col = *((int*)bytes); bytes += sizeof(int);
2139-
int flags = *((int*)bytes); bytes += sizeof(int);
2139+
unsigned flags = *((unsigned*)bytes); bytes += sizeof(unsigned);
21402140

21412141
flags = eventModifierFlagsToVimMouseModMask(flags);
21422142

@@ -2147,7 +2147,7 @@ - (void)handleInputEvent:(int)msgid data:(NSData *)data
21472147

21482148
int row = *((int*)bytes); bytes += sizeof(int);
21492149
int col = *((int*)bytes); bytes += sizeof(int);
2150-
int flags = *((int*)bytes); bytes += sizeof(int);
2150+
unsigned flags = *((unsigned*)bytes); bytes += sizeof(unsigned);
21512151

21522152
flags = eventModifierFlagsToVimMouseModMask(flags);
21532153

@@ -2607,7 +2607,7 @@ - (void)handleScrollbarEvent:(NSData *)data
26072607

26082608
const void *bytes = [data bytes];
26092609
int32_t ident = *((int32_t*)bytes); bytes += sizeof(int32_t);
2610-
int hitPart = *((int*)bytes); bytes += sizeof(int);
2610+
unsigned hitPart = *((unsigned*)bytes); bytes += sizeof(unsigned);
26112611
float fval = *((float*)bytes); bytes += sizeof(float);
26122612
scrollbar_T *sb = gui_find_scrollbar(ident);
26132613

@@ -2765,7 +2765,7 @@ - (void)handleDropString:(NSData *)data
27652765
#ifdef FEAT_DND
27662766
char_u dropkey[3] = { CSI, KS_EXTRA, (char_u)KE_DROP };
27672767
const void *bytes = [data bytes];
2768-
int len = *((int*)bytes); bytes += sizeof(int);
2768+
int len = *((int*)bytes); bytes += sizeof(int); // unused
27692769
NSMutableString *string = [NSMutableString stringWithUTF8String:bytes];
27702770

27712771
// Replace unrecognized end-of-line sequences with \x0a (line feed).
@@ -2778,7 +2778,7 @@ - (void)handleDropString:(NSData *)data
27782778
options:0 range:range];
27792779
}
27802780

2781-
len = [string lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
2781+
len = (int)[string lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
27822782
char_u *s = (char_u*)[string UTF8String];
27832783
if (input_conv.vc_type != CONV_NONE)
27842784
s = string_convert(&input_conv, s, &len);
@@ -3517,9 +3517,9 @@ - (void)handleMarkedText:(NSData *)data
35173517
- (void)handleGesture:(NSData *)data
35183518
{
35193519
const void *bytes = [data bytes];
3520-
int flags = *((int*)bytes); bytes += sizeof(int);
3520+
unsigned flags = *((int*)bytes); bytes += sizeof(int);
35213521
int gesture = *((int*)bytes); bytes += sizeof(int);
3522-
int modifiers = eventModifierFlagsToVimModMask(flags);
3522+
unsigned modifiers = eventModifierFlagsToVimModMask(flags);
35233523
char_u string[6];
35243524

35253525
string[3] = CSI;
@@ -3761,7 +3761,7 @@ - (NSComparisonResult)serverNameCompare:(NSString *)string
37613761

37623762

37633763

3764-
static int eventModifierFlagsToVimModMask(int modifierFlags)
3764+
static unsigned eventModifierFlagsToVimModMask(unsigned modifierFlags)
37653765
{
37663766
int modMask = 0;
37673767

@@ -3777,9 +3777,9 @@ static int eventModifierFlagsToVimModMask(int modifierFlags)
37773777
return modMask;
37783778
}
37793779

3780-
static int eventModifierFlagsToVimMouseModMask(int modifierFlags)
3780+
static unsigned eventModifierFlagsToVimMouseModMask(unsigned modifierFlags)
37813781
{
3782-
int modMask = 0;
3782+
unsigned modMask = 0;
37833783

37843784
if (modifierFlags & NSEventModifierFlagShift)
37853785
modMask |= MOUSE_SHIFT;

0 commit comments

Comments
 (0)