Skip to content

Commit

Permalink
Fix compilation warnings in macOS build, enable `warnings=extra werro…
Browse files Browse the repository at this point in the history
…r=yes` for macOS CI.
  • Loading branch information
bruvzg committed Oct 24, 2019
1 parent 79dae3a commit 7b64340
Show file tree
Hide file tree
Showing 18 changed files with 36 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ matrix:

- name: macOS editor (debug, Clang)
stage: build
env: PLATFORM=osx TOOLS=yes TARGET=debug CACHE_NAME=${PLATFORM}-tools-clang
env: PLATFORM=osx TOOLS=yes TARGET=debug CACHE_NAME=${PLATFORM}-tools-clang EXTRA_ARGS="warnings=extra werror=yes"
os: osx
compiler: clang

Expand Down
8 changes: 4 additions & 4 deletions drivers/coreaudio/audio_driver_coreaudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,15 @@ OSStatus AudioDriverCoreAudio::output_callback(void *inRefCon,
for (unsigned int i = 0; i < ioData->mNumberBuffers; i++) {

AudioBuffer *abuf = &ioData->mBuffers[i];
int frames_left = inNumberFrames;
unsigned int frames_left = inNumberFrames;
int16_t *out = (int16_t *)abuf->mData;

while (frames_left) {

int frames = MIN(frames_left, ad->buffer_frames);
unsigned int frames = MIN(frames_left, ad->buffer_frames);
ad->audio_server_process(frames, ad->samples_in.ptrw());

for (int j = 0; j < frames * ad->channels; j++) {
for (unsigned int j = 0; j < frames * ad->channels; j++) {

out[j] = ad->samples_in[j] >> 16;
}
Expand Down Expand Up @@ -231,7 +231,7 @@ OSStatus AudioDriverCoreAudio::input_callback(void *inRefCon,

OSStatus result = AudioUnitRender(ad->input_unit, ioActionFlags, inTimeStamp, inBusNumber, inNumberFrames, &bufferList);
if (result == noErr) {
for (int i = 0; i < inNumberFrames * ad->capture_channels; i++) {
for (unsigned int i = 0; i < inNumberFrames * ad->capture_channels; i++) {
int32_t sample = ad->input_buf[i] << 16;
ad->capture_buffer_write(sample);

Expand Down
2 changes: 1 addition & 1 deletion drivers/coremidi/midi_driver_coremidi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

void MIDIDriverCoreMidi::read(const MIDIPacketList *packet_list, void *read_proc_ref_con, void *src_conn_ref_con) {
MIDIPacket *packet = const_cast<MIDIPacket *>(packet_list->packet);
for (int i = 0; i < packet_list->numPackets; i++) {
for (UInt32 i = 0; i < packet_list->numPackets; i++) {
receive_input_packet(packet->timeStamp, packet->data, packet->length);
packet = MIDIPacketNext(packet);
}
Expand Down
2 changes: 2 additions & 0 deletions drivers/unix/os_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ void OS_Unix::initialize_core() {
RWLockDummy::make_default();
#else
ThreadPosix::make_default();
#if !defined(OSX_ENABLED) && !defined(IPHONE_ENABLED)
SemaphorePosix::make_default();
#endif
MutexPosix::make_default();
RWLockPosix::make_default();
#endif
Expand Down
2 changes: 1 addition & 1 deletion drivers/unix/semaphore_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

#include "semaphore_posix.h"

#if defined(UNIX_ENABLED) || defined(PTHREAD_ENABLED)
#if (defined(UNIX_ENABLED) || defined(PTHREAD_ENABLED)) && !defined(OSX_ENABLED) && !defined(IPHONE_ENABLED)

#include "core/os/memory.h"
#include <errno.h>
Expand Down
2 changes: 1 addition & 1 deletion drivers/unix/semaphore_posix.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

#include "core/os/semaphore.h"

#if defined(UNIX_ENABLED) || defined(PTHREAD_ENABLED)
#if (defined(UNIX_ENABLED) || defined(PTHREAD_ENABLED)) && !defined(OSX_ENABLED) && !defined(IPHONE_ENABLED)

#include <semaphore.h>

Expand Down
2 changes: 1 addition & 1 deletion drivers/wasapi/audio_driver_wasapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class CMMNotificationClient : public IMMNotificationClient {
CMMNotificationClient() :
_cRef(1),
_pEnumerator(NULL) {}
~CMMNotificationClient() {
virtual ~CMMNotificationClient() {
if ((_pEnumerator) != NULL) {
(_pEnumerator)->Release();
(_pEnumerator) = NULL;
Expand Down
2 changes: 0 additions & 2 deletions platform/iphone/gl_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@
@property(strong, nonatomic) AVPlayer *avPlayer;
@property(strong, nonatomic) AVPlayerLayer *avPlayerLayer;

// Old videoplayer properties
@property(strong, nonatomic) MPMoviePlayerController *moviePlayerController;
@property(strong, nonatomic) UIWindow *backgroundWindow;

@property(nonatomic) UITextAutocorrectionType autocorrectionType;
Expand Down
36 changes: 0 additions & 36 deletions platform/iphone/gl_view.mm
Original file line number Diff line number Diff line change
Expand Up @@ -729,40 +729,4 @@ - (void)playerItemDidReachEnd:(NSNotification *)notification {
_stop_video();
}

/*
- (void)moviePlayBackDidFinish:(NSNotification*)notification {
NSNumber* reason = [[notification userInfo] objectForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey];
switch ([reason intValue]) {
case MPMovieFinishReasonPlaybackEnded:
//NSLog(@"Playback Ended");
break;
case MPMovieFinishReasonPlaybackError:
//NSLog(@"Playback Error");
video_found_error = true;
break;
case MPMovieFinishReasonUserExited:
//NSLog(@"User Exited");
video_found_error = true;
break;
default:
//NSLog(@"Unsupported reason!");
break;
}
MPMoviePlayerController *player = [notification object];
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
[_instance.moviePlayerController stop];
[_instance.moviePlayerController.view removeFromSuperview];
video_playing = false;
}
*/

@end
2 changes: 1 addition & 1 deletion platform/iphone/godot_iphone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ int iphone_main(int, int, int, char **, String);

int iphone_main(int width, int height, int argc, char **argv, String data_dir) {

int len = strlen(argv[0]);
size_t len = strlen(argv[0]);

while (len--) {
if (argv[0][len] == '/') break;
Expand Down
2 changes: 1 addition & 1 deletion platform/iphone/in_app_store.mm
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ - (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProdu
PoolStringArray localized_prices;
PoolStringArray currency_codes;

for (int i = 0; i < [products count]; i++) {
for (NSUInteger i = 0; i < [products count]; i++) {

SKProduct *product = [products objectAtIndex:i];

Expand Down
8 changes: 4 additions & 4 deletions platform/osx/camera_osx.mm
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CM

{
// do Y
int new_width = CVPixelBufferGetWidthOfPlane(pixelBuffer, 0);
int new_height = CVPixelBufferGetHeightOfPlane(pixelBuffer, 0);
size_t new_width = CVPixelBufferGetWidthOfPlane(pixelBuffer, 0);
size_t new_height = CVPixelBufferGetHeightOfPlane(pixelBuffer, 0);

if ((width[0] != new_width) || (height[0] != new_height)) {
width[0] = new_width;
Expand All @@ -168,8 +168,8 @@ - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CM

{
// do CbCr
int new_width = CVPixelBufferGetWidthOfPlane(pixelBuffer, 1);
int new_height = CVPixelBufferGetHeightOfPlane(pixelBuffer, 1);
size_t new_width = CVPixelBufferGetWidthOfPlane(pixelBuffer, 1);
size_t new_height = CVPixelBufferGetHeightOfPlane(pixelBuffer, 1);

if ((width[1] != new_width) || (height[1] != new_height)) {
width[1] = new_width;
Expand Down
4 changes: 2 additions & 2 deletions platform/osx/crash_handler_osx.mm
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ static void handle_crash(int sig) {
if (strings) {
void *load_addr = (void *)load_address();

for (int i = 1; i < size; i++) {
for (size_t i = 1; i < size; i++) {
char fname[1024];
Dl_info info;

Expand Down Expand Up @@ -142,7 +142,7 @@ static void handle_crash(int sig) {
}
}

fprintf(stderr, "[%d] %ls\n", i, output.c_str());
fprintf(stderr, "[%zu] %ls\n", i, output.c_str());
}

free(strings);
Expand Down
3 changes: 3 additions & 0 deletions platform/osx/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ def configure(env):
env['RANLIB'] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-ranlib"
env['AS'] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-as"
env.Append(CPPDEFINES=['__MACPORTS__']) #hack to fix libvpx MM256_BROADCASTSI128_SI256 define
else:
env['CC'] = 'clang'
env['CXX'] = 'clang++'

detect_darwin_sdk_path('osx', env)
env.Append(CCFLAGS=['-isysroot', '$MACOS_SDK_PATH'])
Expand Down
2 changes: 1 addition & 1 deletion platform/osx/joypad_osx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ JoypadOSX::JoypadOSX() {
const size_t n_elements = sizeof(vals) / sizeof(vals[0]);
CFArrayRef array = okay ? CFArrayCreate(kCFAllocatorDefault, vals, n_elements, &kCFTypeArrayCallBacks) : NULL;

for (int i = 0; i < n_elements; i++) {
for (size_t i = 0; i < n_elements; i++) {
if (vals[i]) {
CFRelease((CFTypeRef)vals[i]);
}
Expand Down
3 changes: 3 additions & 0 deletions platform/osx/os_osx.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#ifndef OS_OSX_H
#define OS_OSX_H

#define BitMap _QDBitMap // Suppress deprecated QuickDraw definition.

#include "camera_osx.h"
#include "core/os/input.h"
#include "crash_handler_osx.h"
Expand All @@ -50,6 +52,7 @@
#include <ApplicationServices/ApplicationServices.h>
#include <CoreVideo/CoreVideo.h>

#undef BitMap
#undef CursorShape

class OS_OSX : public OS_Unix {
Expand Down
16 changes: 8 additions & 8 deletions platform/osx/os_osx.mm
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ - (BOOL)performDragOperation:(id<NSDraggingInfo>)sender {
NSArray *filenames = [pboard propertyListForType:NSFilenamesPboardType];

Vector<String> files;
for (int i = 0; i < filenames.count; i++) {
for (NSUInteger i = 0; i < filenames.count; i++) {
NSString *ns = [filenames objectAtIndex:i];
char *utfs = strdup([ns UTF8String]);
String ret;
Expand Down Expand Up @@ -1502,7 +1502,7 @@ static void displays_arrangement_changed(CGDirectDisplayID display_id, CGDisplay
[window_object setContentView:window_view];
[window_object setDelegate:window_delegate];
[window_object setAcceptsMouseMovedEvents:YES];
[window_object center];
[(NSWindow *)window_object center];

[window_object setRestorable:NO];

Expand Down Expand Up @@ -2338,12 +2338,12 @@ static int get_screen_index(NSScreen *screen) {
};

Point2 OS_OSX::get_native_screen_position(int p_screen) const {
if (p_screen == -1) {
if (p_screen < 0) {
p_screen = get_current_screen();
}

NSArray *screenArray = [NSScreen screens];
if (p_screen < [screenArray count]) {
if ((NSUInteger)p_screen < [screenArray count]) {
float display_scale = _display_scale([screenArray objectAtIndex:p_screen]);
NSRect nsrect = [[screenArray objectAtIndex:p_screen] frame];
// Return the top-left corner of the screen, for OS X the y starts at the bottom
Expand All @@ -2362,12 +2362,12 @@ static int get_screen_index(NSScreen *screen) {
}

int OS_OSX::get_screen_dpi(int p_screen) const {
if (p_screen == -1) {
if (p_screen < 0) {
p_screen = get_current_screen();
}

NSArray *screenArray = [NSScreen screens];
if (p_screen < [screenArray count]) {
if ((NSUInteger)p_screen < [screenArray count]) {
float displayScale = _display_scale([screenArray objectAtIndex:p_screen]);
NSDictionary *description = [[screenArray objectAtIndex:p_screen] deviceDescription];
NSSize displayPixelSize = [[description objectForKey:NSDeviceSize] sizeValue];
Expand All @@ -2381,12 +2381,12 @@ static int get_screen_index(NSScreen *screen) {
}

Size2 OS_OSX::get_screen_size(int p_screen) const {
if (p_screen == -1) {
if (p_screen < 0) {
p_screen = get_current_screen();
}

NSArray *screenArray = [NSScreen screens];
if (p_screen < [screenArray count]) {
if ((NSUInteger)p_screen < [screenArray count]) {
float displayScale = _display_scale([screenArray objectAtIndex:p_screen]);
// Note: Use frame to get the whole screen size
NSRect nsrect = [[screenArray objectAtIndex:p_screen] frame];
Expand Down
3 changes: 2 additions & 1 deletion platform/windows/os_windows.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ class OS_Windows : public OS {
KEY_EVENT_BUFFER_SIZE = 512
};

#ifdef STDOUT_FILE
FILE *stdo;
#endif

struct KeyEvent {

Expand All @@ -107,7 +109,6 @@ class OS_Windows : public OS {
VisualServer *visual_server;
CameraWindows *camera_server;
int pressrc;
HDC hDC; // Private GDI Device Context
HINSTANCE hInstance; // Holds The Instance Of The Application
HWND hWnd;
Point2 last_pos;
Expand Down

0 comments on commit 7b64340

Please sign in to comment.