Browse files

Fix clang compiler and static analyzer warnings

  • Loading branch information...
1 parent ce5b7a2 commit 8545368b421bcfead61a215301b224e900bbd2d6 @b4winckler committed Aug 17, 2012
View
10 src/MacVim/MMAppController.m
@@ -1205,7 +1205,7 @@ - (IBAction)atsuiButtonClicked:(id)sender
kCFPreferencesCurrentApplication);
CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
- ASLogInfo(@"Use renderer=%d", renderer);
+ ASLogInfo(@"Use renderer=%ld", renderer);
// This action is called when the user clicks the "use ATSUI renderer"
// button in the advanced preferences pane.
@@ -1807,8 +1807,8 @@ - (NSMutableDictionary *)extractArgumentsFromOdocEvent:
[dict setObject:NSStringFromRange(range) forKey:@"selectionRange"];
} else {
- ASLogErr(@"Xcode selection range size mismatch! got=%d expected=%d",
- length, sizeof(MMXcodeSelectionRange));
+ ASLogErr(@"Xcode selection range size mismatch! got=%ld "
+ "expected=%ld", length, sizeof(MMXcodeSelectionRange));
}
}
@@ -2393,11 +2393,11 @@ - (NSDictionary *)convertVimControllerArguments:(NSDictionary *)args
if (r.length > 0) {
// Select given range of characters.
// TODO: This only works for encodings where 1 byte == 1 character
- [a addObject:[NSString stringWithFormat:@"norm %dgov%dgo",
+ [a addObject:[NSString stringWithFormat:@"norm %ldgov%ldgo",
r.location, NSMaxRange(r)-1]];
} else {
// Position cursor on line at start of range.
- [a addObject:[NSString stringWithFormat:@"norm %dGz.0",
+ [a addObject:[NSString stringWithFormat:@"norm %ldGz.0",
r.location]];
}
View
8 src/MacVim/MMBackend.m
@@ -1544,7 +1544,7 @@ - (NSString *)peekForReplyOnPort:(int)port
NSNumber *key = [NSNumber numberWithInt:port];
NSMutableArray *replies = [serverReplyDict objectForKey:key];
if (replies && [replies count]) {
- ASLogDebug(@" %d replies, topmost is: %@", [replies count],
+ ASLogDebug(@" %ld replies, topmost is: %@", [replies count],
[replies objectAtIndex:0]);
return [replies objectAtIndex:0];
}
@@ -2101,7 +2101,7 @@ - (void)doKeyDown:(NSString *)key
keyCode:(unsigned)code
modifiers:(int)mods
{
- ASLogDebug(@"key='%@' code=%#x mods=%#x length=%d", key, code, mods,
+ ASLogDebug(@"key='%@' code=%#x mods=%#x length=%ld", key, code, mods,
[key length]);
if (!key) return;
@@ -2829,10 +2829,10 @@ - (void)handleOpenWithArguments:(NSDictionary *)args
NSString *cmd;
if (range.length > 0) {
// TODO: This only works for encodings where 1 byte == 1 character
- cmd = [NSString stringWithFormat:@"<C-\\><C-N>%dgov%dgo",
+ cmd = [NSString stringWithFormat:@"<C-\\><C-N>%ldgov%ldgo",
range.location, NSMaxRange(range)-1];
} else {
- cmd = [NSString stringWithFormat:@"<C-\\><C-N>%dGz.0",
+ cmd = [NSString stringWithFormat:@"<C-\\><C-N>%ldGz.0",
range.location];
}
View
3 src/MacVim/MMCoreTextView.m
@@ -1033,12 +1033,11 @@ - (void)batchDrawData:(NSData *)data
CFStringRef strRef = CFStringCreateWithCharactersNoCopy(
NULL, chars, count, kCFAllocatorNull);
CTFontRef newFontRef = CTFontCreateForString(fontRef, strRef, r);
+ CFRelease(strRef);
if (!newFontRef) {
- ASLogNotice(@"Cannot find font to draw chars: %@", strRef);
CGFontRelease(cgFontRef);
return;
}
- CFRelease(strRef);
recurseDraw(chars, glyphs, advances, count, context, newFontRef,
x0, y);
View
3 src/MacVim/MMTextStorage.m
@@ -123,7 +123,8 @@ - (void)replaceCharactersInRange:(NSRange)range
withString:(NSString *)string
{
#if MM_TS_PARANOIA_LOG
- ASLogWarn(@"Calling %s on MMTextStorage is unsupported", _cmd);
+ ASLogWarn(@"Calling %@ on MMTextStorage is unsupported",
+ NSStringFromSelector(_cmd));
#endif
//[attribString replaceCharactersInRange:range withString:string];
}
View
2 src/MacVim/MMTextView.m
@@ -95,7 +95,7 @@ - (id)initWithFrame:(NSRect)frame
// system. Releasing the text storage will in turn release the layout
// manager, the text container, and finally the text view (self). This
// complicates deallocation somewhat, see -[MMVimView dealloc].
- if (![super initWithFrame:frame textContainer:tc]) {
+ if (!(self = [super initWithFrame:frame textContainer:tc])) {
[textStorage release];
return nil;
}
View
32 src/MacVim/MMVimController.m
@@ -281,11 +281,11 @@ - (void)dropFiles:(NSArray *)filenames forceOpen:(BOOL)force
- (void)file:(NSString *)filename draggedToTabAtIndex:(NSUInteger)tabIndex
{
filename = normalizeFilename(filename);
- ASLogInfo(@"filename=%@ index=%d", filename, tabIndex);
+ ASLogInfo(@"filename=%@ index=%ld", filename, tabIndex);
NSString *fnEsc = [filename stringByEscapingSpecialFilenameCharacters];
NSString *input = [NSString stringWithFormat:@"<C-\\><C-N>:silent "
- "tabnext %d |"
+ "tabnext %ld |"
"edit! %@<CR>", tabIndex + 1, fnEsc];
[self addVimInput:input];
}
@@ -540,7 +540,7 @@ - (void)doProcessInputQueue:(NSArray *)queue
}
if (delayQueue) {
- ASLogDebug(@" Flushing delay queue (%d items)",
+ ASLogDebug(@" Flushing delay queue (%ld items)",
[delayQueue count]/2);
[self performSelector:@selector(processInputQueue:)
withObject:delayQueue
@@ -579,7 +579,7 @@ - (void)handleMessage:(int)msgid data:(NSData *)data
SetTextDimensionsReplyMsgID == msgid) {
const void *bytes = [data bytes];
int rows = *((int*)bytes); bytes += sizeof(int);
- int cols = *((int*)bytes); bytes += sizeof(int);
+ int cols = *((int*)bytes);
// NOTE: When a resize message originated in the frontend, Vim
// acknowledges it with a reply message. When this happens the window
@@ -642,7 +642,7 @@ - (void)handleMessage:(int)msgid data:(NSData *)data
} else if (ShowToolbarMsgID == msgid) {
const void *bytes = [data bytes];
int enable = *((int*)bytes); bytes += sizeof(int);
- int flags = *((int*)bytes); bytes += sizeof(int);
+ int flags = *((int*)bytes);
int mode = NSToolbarDisplayModeDefault;
if (flags & ToolbarLabelFlag) {
@@ -659,33 +659,33 @@ - (void)handleMessage:(int)msgid data:(NSData *)data
} else if (CreateScrollbarMsgID == msgid) {
const void *bytes = [data bytes];
int32_t ident = *((int32_t*)bytes); bytes += sizeof(int32_t);
- int type = *((int*)bytes); bytes += sizeof(int);
+ int type = *((int*)bytes);
[windowController createScrollbarWithIdentifier:ident type:type];
} else if (DestroyScrollbarMsgID == msgid) {
const void *bytes = [data bytes];
- int32_t ident = *((int32_t*)bytes); bytes += sizeof(int32_t);
+ int32_t ident = *((int32_t*)bytes);
[windowController destroyScrollbarWithIdentifier:ident];
} else if (ShowScrollbarMsgID == msgid) {
const void *bytes = [data bytes];
int32_t ident = *((int32_t*)bytes); bytes += sizeof(int32_t);
- int visible = *((int*)bytes); bytes += sizeof(int);
+ int visible = *((int*)bytes);
[windowController showScrollbarWithIdentifier:ident state:visible];
} else if (SetScrollbarPositionMsgID == msgid) {
const void *bytes = [data bytes];
int32_t ident = *((int32_t*)bytes); bytes += sizeof(int32_t);
int pos = *((int*)bytes); bytes += sizeof(int);
- int len = *((int*)bytes); bytes += sizeof(int);
+ int len = *((int*)bytes);
[windowController setScrollbarPosition:pos length:len
identifier:ident];
} else if (SetScrollbarThumbMsgID == msgid) {
const void *bytes = [data bytes];
int32_t ident = *((int32_t*)bytes); bytes += sizeof(int32_t);
float val = *((float*)bytes); bytes += sizeof(float);
- float prop = *((float*)bytes); bytes += sizeof(float);
+ float prop = *((float*)bytes);
[windowController setScrollbarThumbValue:val proportion:prop
identifier:ident];
@@ -724,7 +724,7 @@ - (void)handleMessage:(int)msgid data:(NSData *)data
} else if (SetDefaultColorsMsgID == msgid) {
const void *bytes = [data bytes];
unsigned bg = *((unsigned*)bytes); bytes += sizeof(unsigned);
- unsigned fg = *((unsigned*)bytes); bytes += sizeof(unsigned);
+ unsigned fg = *((unsigned*)bytes);
NSColor *back = [NSColor colorWithArgbInt:bg];
NSColor *fore = [NSColor colorWithRgbInt:fg];
@@ -750,12 +750,12 @@ - (void)handleMessage:(int)msgid data:(NSData *)data
afterDelay:0];
} else if (SetMouseShapeMsgID == msgid) {
const void *bytes = [data bytes];
- int shape = *((int*)bytes); bytes += sizeof(int);
+ int shape = *((int*)bytes);
[windowController setMouseShape:shape];
} else if (AdjustLinespaceMsgID == msgid) {
const void *bytes = [data bytes];
- int linespace = *((int*)bytes); bytes += sizeof(int);
+ int linespace = *((int*)bytes);
[windowController adjustLinespace:linespace];
} else if (ActivateMsgID == msgid) {
@@ -779,7 +779,7 @@ - (void)handleMessage:(int)msgid data:(NSData *)data
const void *bytes = [data bytes];
// state < 0 <-> some buffer modified
// state > 0 <-> current buffer modified
- int state = *((int*)bytes); bytes += sizeof(int);
+ int state = *((int*)bytes);
// NOTE: The window controller tracks whether current buffer is
// modified or not (and greys out the proxy icon as well as putting a
@@ -842,15 +842,15 @@ - (void)handleMessage:(int)msgid data:(NSData *)data
const void *bytes = [data bytes];
int rows = *((int*)bytes); bytes += sizeof(int);
int cols = *((int*)bytes); bytes += sizeof(int);
- int state = *((int*)bytes); bytes += sizeof(int);
+ int state = *((int*)bytes);
[windowController zoomWithRows:rows
columns:cols
state:state];
} else if (SetWindowPositionMsgID == msgid) {
const void *bytes = [data bytes];
int x = *((int*)bytes); bytes += sizeof(int);
- int y = *((int*)bytes); bytes += sizeof(int);
+ int y = *((int*)bytes);
// NOTE: Vim measures Y-coordinates from top of screen.
NSRect frame = [[[windowController window] screen] frame];
View
6 src/MacVim/MMVimView.m
@@ -83,7 +83,7 @@ @implementation MMVimView
- (MMVimView *)initWithFrame:(NSRect)frame
vimController:(MMVimController *)controller
{
- if (![super initWithFrame:frame])
+ if (!(self = [super initWithFrame:frame]))
return nil;
vimController = controller;
@@ -95,7 +95,7 @@ - (MMVimView *)initWithFrame:(NSRect)frame
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
NSInteger renderer = [ud integerForKey:MMRendererKey];
- ASLogInfo(@"Use renderer=%d", renderer);
+ ASLogInfo(@"Use renderer=%ld", renderer);
#if MM_ENABLE_ATSUI
if (MMRendererATSUI == renderer) {
@@ -107,7 +107,7 @@ - (MMVimView *)initWithFrame:(NSRect)frame
if (MMRendererCoreText == renderer) {
// HACK! 'textView' has type MMTextView, but MMCoreTextView is not
// derived from MMTextView.
- textView = [[MMCoreTextView alloc] initWithFrame:frame];
+ textView = (MMTextView *)[[MMCoreTextView alloc] initWithFrame:frame];
}
#endif
else {
View
11 src/MacVim/gui_macvim.m
@@ -177,7 +177,7 @@
kCFPreferencesCurrentApplication,
&keyValid);
if (keyValid) {
- ASLogInfo(@"Use renderer=%d", val);
+ ASLogInfo(@"Use renderer=%ld", val);
use_gui_macvim_draw_string = (val != MMRendererCoreText);
// For now only the Core Text renderer knows how to render graphical
@@ -593,7 +593,7 @@
gui.def_back_pixel = gui.back_pixel;
gui.def_norm_pixel = gui.norm_pixel;
- ASLogDebug(@"back=%x norm=%x", gui.def_back_pixel, gui.def_norm_pixel);
+ ASLogDebug(@"back=%ld norm=%ld", gui.def_back_pixel, gui.def_norm_pixel);
[[MMBackend sharedInstance]
setDefaultColorsBackground:gui.def_back_pixel
@@ -748,7 +748,8 @@
? menu->strings[MENU_INDEX_TIP] : menu->actext;
NSArray *desc = descriptor_for_menu(menu);
NSString *keyEquivalent = menu->mac_key
- ? [NSString stringWithFormat:@"%C", specialKeyToNSKey(menu->mac_key)]
+ ? [NSString stringWithFormat:@"%C",
+ (unsigned short)specialKeyToNSKey(menu->mac_key)]
: [NSString string];
int modifierMask = vimModMaskToEventModifierFlags(menu->mac_mods);
char_u *icon = NULL;
@@ -917,7 +918,7 @@
GuiFont font;
{
if (font != NOFONT) {
- ASLogDebug(@"font=0x%x", font);
+ ASLogDebug(@"font=%p", font);
[(id)font release];
}
}
@@ -1559,7 +1560,7 @@
void
gui_mch_get_screen_dimensions(int *screen_w, int *screen_h)
{
- ASLogDebug(@"Columns=%d Rows=%d", Columns, Rows);
+ ASLogDebug(@"Columns=%ld Rows=%ld", Columns, Rows);
*screen_w = Columns;
*screen_h = Rows;
}

0 comments on commit 8545368

Please sign in to comment.