Commit 827b8e61 authored by David Fuhrmann's avatar David Fuhrmann

macosx: fix some static code analysis warnings

Most of them are memleaks, uninitialized values, unused code
and type mismatches (float / int vs. CGFloat, uint vs. int)
parent 58d4ebc3
......@@ -284,7 +284,9 @@ static VLCAudioEffects *_o_sharedInstance = nil;
i_old_profile_index = [o_profile_pop indexOfSelectedItem];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSUInteger selectedProfile = [o_profile_pop indexOfSelectedItem];
NSInteger selectedProfile = [o_profile_pop indexOfSelectedItem];
if (selectedProfile < 0)
return;
audio_output_t *p_aout = getAout();
playlist_t *p_playlist = pl_Get(p_intf);
......@@ -301,7 +303,7 @@ static VLCAudioEffects *_o_sharedInstance = nil;
}
/* fetch preset */
NSArray *items = [[[defaults objectForKey:@"AudioEffectProfiles"] objectAtIndex:selectedProfile] componentsSeparatedByString:@";"];
NSArray *items = [[[defaults objectForKey:@"AudioEffectProfiles"] objectAtIndex:(NSUInteger) selectedProfile] componentsSeparatedByString:@";"];
/* eq preset */
vlc_object_t *p_object = VLC_OBJECT(getAout());
......@@ -947,7 +949,7 @@ static bool GetEqualizerStatus(intf_thread_t *p_custom_intf,
- (IBAction)spat_sliderUpdated:(id)sender
{
audio_output_t *p_aout = getAout();
char *value;
char *value = NULL;
if (sender == o_spat_band1_sld)
value = "spatializer-roomsize";
else if (sender == o_spat_band2_sld)
......
......@@ -146,7 +146,7 @@
// remove fullscreen button for lion fullscreen
if (b_nativeFullscreenMode) {
float f_width = [o_fullscreen_btn frame].size.width;
CGFloat f_width = [o_fullscreen_btn frame].size.width;
NSRect frame = [o_time_fld frame];
frame.origin.x += f_width;
......@@ -447,6 +447,14 @@
[o_fullscreen_btn setState:b_fullscreen];
}
- (void)dealloc {
[o_play_img release];
[o_play_pressed_img release];
[o_pause_img release];
[o_pause_pressed_img release];
[super dealloc];
}
@end
......@@ -645,7 +653,7 @@ else \
[[item animator] setFrame: frame]
NSRect frame;
float f_space = [o_effects_btn frame].size.width;
CGFloat f_space = [o_effects_btn frame].size.width;
// extra margin between button and volume up button
if (b_nativeFullscreenMode)
f_space += 2;
......@@ -695,7 +703,7 @@ else \
[[item animator] setFrame: frame]
NSRect frame;
float f_space = [o_effects_btn frame].size.width;
CGFloat f_space = [o_effects_btn frame].size.width;
// extra margin between button and volume up button
if (b_nativeFullscreenMode)
f_space += 2;
......@@ -925,7 +933,7 @@ else \
- (void)addPlaymodeButtons:(BOOL)b_fast
{
NSRect frame;
float f_space = [o_repeat_btn frame].size.width + [o_shuffle_btn frame].size.width - 6.;
CGFloat f_space = [o_repeat_btn frame].size.width + [o_shuffle_btn frame].size.width - 6.;
if (b_dark_interface) {
[[o_playlist_btn animator] setImage:[NSImage imageNamed:@"playlist_dark"]];
......@@ -958,7 +966,7 @@ else \
- (void)removePlaymodeButtons:(BOOL)b_fast
{
NSRect frame;
float f_space = [o_repeat_btn frame].size.width + [o_shuffle_btn frame].size.width - 6.;
CGFloat f_space = [o_repeat_btn frame].size.width + [o_shuffle_btn frame].size.width - 6.;
[o_repeat_btn setHidden: YES];
[o_shuffle_btn setHidden: YES];
......@@ -1142,4 +1150,18 @@ else \
[[VLCMainMenu sharedInstance] setRateControlsEnabled: b_control];
}
- (void)dealloc {
[o_repeat_img release];
[o_repeat_pressed_img release];
[o_repeat_all_img release];
[o_repeat_all_pressed_img release];
[o_repeat_one_img release];
[o_repeat_one_pressed_img release];
[o_shuffle_img release];
[o_shuffle_pressed_img release];
[o_shuffle_on_img release];
[o_shuffle_on_pressed_img release];
[super dealloc];
}
@end
......@@ -826,7 +826,7 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
- (NSString *)currentEncapsulationFormatAsFileExtension:(BOOL)b_extension
{
NSUInteger cellTag = [[_customize_encap_matrix selectedCell] tag];
NSUInteger cellTag = (NSUInteger) [[_customize_encap_matrix selectedCell] tag];
NSString * returnValue;
switch (cellTag) {
case MPEGTS:
......
......@@ -35,9 +35,6 @@
#import <vlc_strings.h>
#import <vlc_url.h>
@interface VLCMainWindow (Internal)
- (void)jumpWithValue:(char *)p_value forward:(BOOL)b_value;
@end
@implementation VLCCoreInteraction
static VLCCoreInteraction *_o_sharedInstance = nil;
......@@ -67,13 +64,6 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
[super dealloc];
}
- (void)awakeFromNib
{
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(applicationWillFinishLaunching:)
name: NSApplicationWillFinishLaunchingNotification
object: nil];
}
#pragma mark -
#pragma mark Playback Controls
......@@ -573,12 +563,11 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
NSUInteger count = [o_values count];
input_thread_t * p_input = pl_CurrentInput(VLCIntf);
BOOL b_returned = NO;
if (count == 1 && p_input) {
b_returned = input_AddSubtitleOSD(p_input, [[o_values objectAtIndex:0] UTF8String], true, true);
int i_result = input_AddSubtitleOSD(p_input, [[o_values objectAtIndex:0] UTF8String], true, true);
vlc_object_release(p_input);
if (!b_returned)
if (i_result == VLC_SUCCESS)
return YES;
}
else if (p_input)
......
......@@ -292,8 +292,11 @@ static VLCMainMenu *_o_sharedInstance = nil;
mi = [[NSMenuItem alloc] initWithTitle: _NS(p_item->list_text[i]) action:NULL keyEquivalent: @""];
else if (p_item->list.i[i])
mi = [[NSMenuItem alloc] initWithTitle: [NSString stringWithFormat: @"%d", p_item->list.i[i]] action:NULL keyEquivalent: @""];
else
else {
msg_Err(p_intf, "item %d of pref %s failed to be created", i, psz_name);
continue;
}
[mi setTarget:self];
[mi setAction:selector];
[mi setTag:p_item->list.i[i]];
......@@ -594,7 +597,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
- (void)refreshVoutDeviceMenu:(NSNotification *)o_notification
{
NSUInteger count = [o_mu_screen numberOfItems];
NSUInteger count = (NSUInteger) [o_mu_screen numberOfItems];
NSMenu * o_submenu = o_mu_screen;
if (count > 0)
[o_submenu removeAllItems];
......@@ -987,7 +990,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
config_PutInt(p_intf, [representedObject UTF8String], intValue);
NSMenu *menu = [sender menu];
NSUInteger count = [menu numberOfItems];
NSUInteger count = (NSUInteger) [menu numberOfItems];
for (NSUInteger x = 0; x < count; x++)
[[menu itemAtIndex:x] setState:NSOffState];
[[menu itemWithTag:intValue] setState:NSOnState];
......@@ -1011,7 +1014,6 @@ static VLCMainMenu *_o_sharedInstance = nil;
- (IBAction)telxNavLink:(id)sender
{
intf_thread_t * p_intf = VLCIntf;
vlc_object_t *p_vbi;
int i_page = 0;
......
......@@ -89,8 +89,8 @@ typedef enum {
BOOL b_splitview_removed;
BOOL b_minimized_view;
NSUInteger i_lastSplitViewHeight;
NSUInteger i_lastLeftSplitViewWidth;
CGFloat f_lastSplitViewHeight;
CGFloat f_lastLeftSplitViewWidth;
NSMutableArray *o_sidebaritems;
......
......@@ -185,7 +185,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
[o_podcast_unsubscribe_cancel_btn setTitle: _NS("Cancel")];
/* interface builder action */
float f_threshold_height = f_min_video_height + [o_controls_bar height];
CGFloat f_threshold_height = f_min_video_height + [o_controls_bar height];
if (b_dark_interface)
f_threshold_height += [o_titlebar_view frame].size.height;
if ([[self contentView] frame].size.height < f_threshold_height)
......@@ -382,7 +382,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
if (b_splitviewShouldBeHidden) {
[self hideSplitView: YES];
i_lastSplitViewHeight = 300;
f_lastSplitViewHeight = 300;
}
/* sanity check for the window size */
......@@ -398,7 +398,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
[o_controls_bar setFullscreenState:YES];
/* restore split view */
i_lastLeftSplitViewWidth = 200;
f_lastLeftSplitViewWidth = 200;
/* trick NSSplitView implementation, which pretends to know better than us */
if (!config_GetInt(VLCIntf, "macosx-show-sidebar"))
[self performSelector:@selector(toggleLeftSubSplitView) withObject:nil afterDelay:0.05];
......@@ -439,7 +439,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
[self setContentMinSize: NSMakeSize(604., 288.)];
NSRect old_frame = [self frame];
float newHeight = [self minSize].height;
CGFloat newHeight = [self minSize].height;
if (old_frame.size.height < newHeight) {
NSRect new_frame = old_frame;
new_frame.origin.y = old_frame.origin.y + old_frame.size.height - newHeight;
......@@ -606,9 +606,9 @@ static VLCMainWindow *_o_sharedInstance = nil;
{
if (b_with_resize) {
NSRect winrect = [self frame];
i_lastSplitViewHeight = [o_split_view frame].size.height;
winrect.size.height = winrect.size.height - i_lastSplitViewHeight;
winrect.origin.y = winrect.origin.y + i_lastSplitViewHeight;
f_lastSplitViewHeight = [o_split_view frame].size.height;
winrect.size.height = winrect.size.height - f_lastSplitViewHeight;
winrect.origin.y = winrect.origin.y + f_lastSplitViewHeight;
[self setFrame: winrect display: YES animate: YES];
}
......@@ -636,8 +636,8 @@ static VLCMainWindow *_o_sharedInstance = nil;
if (b_with_resize) {
NSRect winrect;
winrect = [self frame];
winrect.size.height = winrect.size.height + i_lastSplitViewHeight;
winrect.origin.y = winrect.origin.y - i_lastSplitViewHeight;
winrect.size.height = winrect.size.height + f_lastSplitViewHeight;
winrect.origin.y = winrect.origin.y - f_lastSplitViewHeight;
[self setFrame: winrect display: YES animate: YES];
}
......@@ -782,7 +782,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
if (!b_nonembedded && (!b_nativeFullscreenMode || (b_nativeFullscreenMode && !b_fullscreen)) && frameBeforePlayback.size.width > 0 && frameBeforePlayback.size.height > 0) {
// only resize back to minimum view of this is still desired final state
float f_threshold_height = f_min_video_height + [o_controls_bar height];
CGFloat f_threshold_height = f_min_video_height + [o_controls_bar height];
if(frameBeforePlayback.size.height > f_threshold_height || b_minimized_view) {
[[self animator] setFrame:frameBeforePlayback display:YES];
}
......@@ -887,7 +887,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
- (void)mainSplitViewDidResizeSubviews:(id)object
{
i_lastLeftSplitViewWidth = [o_left_split_view frame].size.width;
f_lastLeftSplitViewWidth = [o_left_split_view frame].size.width;
config_PutInt(VLCIntf, "macosx-show-sidebar", ![o_split_view isSubviewCollapsed:o_left_split_view]);
[[[VLCMain sharedInstance] mainMenu] updateSidebarMenuItem];
}
......@@ -896,7 +896,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
{
[o_split_view adjustSubviews];
if ([o_split_view isSubviewCollapsed:o_left_split_view])
[o_split_view setPosition:i_lastLeftSplitViewWidth ofDividerAtIndex:0];
[o_split_view setPosition:f_lastLeftSplitViewWidth ofDividerAtIndex:0];
else
[o_split_view setPosition:[o_split_view minPossiblePositionOfDividerAtIndex:0] ofDividerAtIndex:0];
[[[VLCMain sharedInstance] mainMenu] updateSidebarMenuItem];
......@@ -1031,10 +1031,9 @@ static VLCMainWindow *_o_sharedInstance = nil;
{
if ([theEvent type] == NSRightMouseDown || ([theEvent type] == NSLeftMouseDown && ([theEvent modifierFlags] & NSControlKeyMask) == NSControlKeyMask)) {
if (item != nil) {
NSMenu * m;
if ([item sdtype] > 0)
{
m = [[NSMenu alloc] init];
NSMenu *m = [[NSMenu alloc] init];
playlist_t * p_playlist = pl_Get(VLCIntf);
BOOL sd_loaded = playlist_IsServicesDiscoveryLoaded(p_playlist, [[item identifier] UTF8String]);
if (!sd_loaded)
......@@ -1042,8 +1041,9 @@ static VLCMainWindow *_o_sharedInstance = nil;
else
[m addItemWithTitle:_NS("Disable") action:@selector(sdmenuhandler:) keyEquivalent:@""];
[[m itemAtIndex:0] setRepresentedObject: [item identifier]];
return [m autorelease];
}
return [m autorelease];
}
}
......
......@@ -330,7 +330,7 @@
if (!p_intf || (!b_nativeFullscreenMode && !p_wnd))
return;
playlist_t *p_playlist = pl_Get(p_intf);
BOOL b_fullscreen = i_full;
BOOL b_fullscreen = i_full != 0;
if (!var_GetBool(p_playlist, "fullscreen") != !b_fullscreen)
var_SetBool(p_playlist, "fullscreen", b_fullscreen);
......
......@@ -30,16 +30,13 @@
* Preamble
*****************************************************************************/
#import <stdlib.h> /* free() */
#import <string.h>
#import "CompatibilityFixes.h"
#import "intf.h"
#import "VideoView.h"
#import "CoreInteraction.h"
#import "MainMenu.h"
#import "MainWindow.h"
#import <vlc_common.h>
#import <vlc_keys.h>
......
......@@ -412,7 +412,7 @@
- (NSRect) customConstrainFrameRect: (NSRect)frameRect toScreen: (NSScreen*)screen
{
NSRect screenRect = [screen visibleFrame];
float difference;
CGFloat difference;
/* Move top edge of the window inside the screen */
difference = NSMaxY (frameRect) - NSMaxY (screenRect);
......@@ -425,7 +425,7 @@
the window */
difference = NSMaxY (screenRect) - NSMaxY (frameRect);
if (_styleMask & NSResizableWindowMask) {
float difference2;
CGFloat difference2;
difference2 = screenRect.origin.y - frameRect.origin.y;
difference2 -= difference;
......@@ -514,17 +514,17 @@
NSPoint topleftbase = NSMakePoint(0, [self frame].size.height);
NSPoint topleftscreen = [self convertBaseToScreen: topleftbase];
unsigned int i_width = size.width;
unsigned int i_height = size.height;
if (i_width < windowMinSize.width)
i_width = windowMinSize.width;
if (i_height < f_min_video_height)
i_height = f_min_video_height;
CGFloat f_width = size.width;
CGFloat f_height = size.height;
if (f_width < windowMinSize.width)
f_width = windowMinSize.width;
if (f_height < f_min_video_height)
f_height = f_min_video_height;
/* Calculate the window's new size */
NSRect new_frame;
new_frame.size.width = [self frame].size.width - [o_video_view frame].size.width + i_width;
new_frame.size.height = [self frame].size.height - [o_video_view frame].size.height + i_height;
new_frame.size.width = [self frame].size.width - [o_video_view frame].size.width + f_width;
new_frame.size.height = [self frame].size.height - [o_video_view frame].size.height + f_height;
new_frame.origin.x = topleftscreen.x;
new_frame.origin.y = topleftscreen.y - new_frame.size.height;
......@@ -583,8 +583,8 @@
NSRect videoWindowFrame = [self frame];
NSRect viewRect = [o_video_view convertRect:[o_video_view bounds] toView: nil];
NSRect contentRect = [self contentRectForFrameRect:videoWindowFrame];
float marginy = viewRect.origin.y + videoWindowFrame.size.height - contentRect.size.height;
float marginx = contentRect.size.width - viewRect.size.width;
CGFloat marginy = viewRect.origin.y + videoWindowFrame.size.height - contentRect.size.height;
CGFloat marginx = contentRect.size.width - viewRect.size.width;
if (o_titlebar_view && b_dark_interface)
marginy += [o_titlebar_view frame].size.height;
......
......@@ -46,7 +46,7 @@
NSTimer *o_scroll_timer;
float f_current;
float f_end;
CGFloat f_end;
NSTimeInterval i_start;
BOOL b_restart;
BOOL b_isSetUp;
......
......@@ -36,7 +36,6 @@
#import "bookmarks.h"
#import "wizard.h"
#import <vlc_interface.h>
#import "CompatibilityFixes.h"
@interface VLCBookmarks (Internal)
......@@ -387,7 +386,7 @@ clear:
input_thread_t * p_input = pl_CurrentInput(VLCIntf);
seekpoint_t **pp_bookmarks;
int i_bookmarks;
id ret;
id ret = @"";
if (!p_input)
return @"";
......
......@@ -785,7 +785,7 @@ static VLCMain *_o_sharedMainInstance = nil;
playlist_t * p_playlist = pl_Get(VLCIntf);
PL_LOCK;
BOOL kidsAround = p_playlist->p_local_category->i_children;
BOOL kidsAround = p_playlist->p_local_category->i_children != 0;
PL_UNLOCK;
if (kidsAround && var_GetBool(p_playlist, "playlist-autostart"))
[[self playlist] playItem:nil];
......@@ -1021,9 +1021,9 @@ static VLCMain *_o_sharedMainInstance = nil;
if ([o_names count] == 1 && psz_uri) {
input_thread_t * p_input = pl_CurrentInput(VLCIntf);
if (p_input) {
BOOL b_returned = input_AddSubtitleOSD(p_input, [[o_names objectAtIndex:0] UTF8String], true, true);
int i_result = input_AddSubtitleOSD(p_input, [[o_names objectAtIndex:0] UTF8String], true, true);
vlc_object_release(p_input);
if (!b_returned) {
if (i_result == VLC_SUCCESS) {
free(psz_uri);
return;
}
......
......@@ -26,7 +26,6 @@
* Preamble
*****************************************************************************/
#include <stdlib.h> /* malloc(), free() */
#include <string.h>
#ifdef HAVE_CONFIG_H
# include "config.h"
......
......@@ -228,7 +228,7 @@
- (BOOL)getObjectValue:(id*)obj forString:(NSString*)string errorDescription:(NSString**)error;
- (bool)isPartialStringValid:(NSString*)partialString newEditingString:(NSString**)newString errorDescription:(NSString**)error;
- (BOOL)isPartialStringValid:(NSString*)partialString newEditingString:(NSString**)newString errorDescription:(NSString**)error;
@end
......
......@@ -488,7 +488,6 @@ void _drawFrameInRect(NSRect frameRect)
- (void)scrollWheel:(NSEvent *)o_event
{
intf_thread_t * p_intf = VLCIntf;
BOOL b_forward = NO;
CGFloat f_deltaY = [o_event deltaY];
CGFloat f_deltaX = [o_event deltaX];
......@@ -593,7 +592,6 @@ void _drawFrameInRect(NSRect frameRect)
- (void)scrollWheel:(NSEvent *)o_event
{
intf_thread_t * p_intf = VLCIntf;
BOOL b_up = NO;
CGFloat f_deltaY = [o_event deltaY];
CGFloat f_deltaX = [o_event deltaX];
......@@ -606,7 +604,6 @@ void _drawFrameInRect(NSRect frameRect)
// positive for left / down, negative otherwise
CGFloat f_delta = f_deltaX + f_deltaY;
CGFloat f_abs;
int i_vlckey;
if (f_delta > 0.0f)
f_abs = f_delta;
......@@ -913,7 +910,7 @@ void _drawFrameInRect(NSRect frameRect)
return YES;
}
- (bool)isPartialStringValid:(NSString*)partialString newEditingString:(NSString**)newString errorDescription:(NSString**)error
- (BOOL)isPartialStringValid:(NSString*)partialString newEditingString:(NSString**)newString errorDescription:(NSString**)error
{
if ([partialString rangeOfCharacterFromSet:o_forbidden_characters options:NSLiteralSearch].location != NSNotFound) {
return NO;
......
......@@ -463,7 +463,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
if ([o_file_custom_timing_ckb state] == NSOnState) {
NSArray * components = [[o_file_starttime_fld stringValue] componentsSeparatedByString:@":"];
NSUInteger componentCount = [components count];
NSInteger tempValue;
NSInteger tempValue = 0;
if (componentCount == 1)
tempValue = [[components objectAtIndex:0] intValue];
else if (componentCount == 2)
......@@ -1493,7 +1493,7 @@ out:
if (channels) {
NSString *channel;
[[o_eyetv_channels_pop menu] addItem: [NSMenuItem separatorItem]];
while (channel = [channels nextObject])
while ((channel = [channels nextObject]) != nil)
/* we have to add items this way, because we accept duplicates
* additionally, we save a bit of time */
[[[o_eyetv_channels_pop menu] addItemWithTitle: channel action: nil keyEquivalent: @""] setTag:++x];
......
......@@ -372,8 +372,7 @@
* port correctly. Not need, if there isn't any path following the
* hostname. */
NSArray * o_urlItems = [[o_stream_address stringValue] componentsSeparatedByString: @"/"];
NSMutableString * o_finalStreamAddress;
o_finalStreamAddress = [[NSMutableString alloc] init];
NSMutableString * o_finalStreamAddress = [[[NSMutableString alloc] init] autorelease];
if ([o_urlItems count] == 1)
[o_finalStreamAddress appendFormat: @"\"%@:%@\"", [o_stream_address stringValue],[o_stream_port stringValue]];
......
......@@ -191,6 +191,11 @@
pointerValue];
}
- (void)dealloc {
[o_outline_dict release];
[super dealloc];
}
@end
@implementation VLCPlaylistCommon (NSOutlineViewDataSource)
......@@ -1594,12 +1599,11 @@
NSUInteger count = [o_values count];
NSMutableArray *o_array = [NSMutableArray arrayWithCapacity:count];
input_thread_t * p_input = pl_CurrentInput(VLCIntf);
BOOL b_returned = NO;
if (count == 1 && p_input) {
b_returned = input_AddSubtitleOSD(p_input, vlc_path2uri([[o_values objectAtIndex:0] UTF8String], NULL), true, true);
int i_result = input_AddSubtitleOSD(p_input, vlc_path2uri([[o_values objectAtIndex:0] UTF8String], NULL), true, true);
vlc_object_release(p_input);
if (!b_returned)
if (i_result == VLC_SUCCESS)
return YES;
}
else if (p_input)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment