diff --git a/libs/openFrameworks/app/ofAppNoWindow.cpp b/libs/openFrameworks/app/ofAppNoWindow.cpp index 3ca8f6e0b89..df462efb6dc 100644 --- a/libs/openFrameworks/app/ofAppNoWindow.cpp +++ b/libs/openFrameworks/app/ofAppNoWindow.cpp @@ -52,10 +52,10 @@ int kbhit() int getch() { - int r; + ssize_t r; unsigned char c; if ((r = read(0, &c, sizeof(c))) < 0) { - return r; + return (int)r; } else { return c; } diff --git a/libs/openFrameworks/communication/ofArduino.cpp b/libs/openFrameworks/communication/ofArduino.cpp index 59765988d28..9b6dc11e9a7 100644 --- a/libs/openFrameworks/communication/ofArduino.cpp +++ b/libs/openFrameworks/communication/ofArduino.cpp @@ -209,8 +209,8 @@ void ofArduino::update() { if (bytesToRead > 0) { bytesToProcess.resize(bytesToRead); //its possible we dont get all the bytes - int bytesRead = _port.readBytes(&bytesToProcess[0], bytesToRead); - for (int i = 0; i < bytesRead; i++) { + long bytesRead = _port.readBytes(&bytesToProcess[0], bytesToRead); + for (long i = 0; i < bytesRead; i++) { processData((char)(bytesToProcess[i])); } } @@ -1369,7 +1369,7 @@ void ofArduino::sendI2CWriteRequest(char slaveAddress, vector bytes, int if (reg >= 0) { sendValueAsTwo7bitBytes(reg); } - for (int i = 0, length = bytes.size(); i < length; i++) { + for (size_t i = 0, length = bytes.size(); i < length; i++) { sendValueAsTwo7bitBytes(bytes[i]); } @@ -1799,7 +1799,7 @@ bool ofArduino::isPin(int pin) const //this returns the pin if its already not within the analog pin map //we need this to check between digital and analog pin mappings -int ofArduino::convertAnalogPinToDigital(size_t pin) const +int ofArduino::convertAnalogPinToDigital(int pin) const { if (pin < analogPinMap.size()) { if (analogPinMap.count(pin) > 0) { @@ -1815,7 +1815,7 @@ int ofArduino::convertAnalogPinToDigital(size_t pin) const //this returns the pin if its already within the analog pin map //we need this to check between digital and analog pin mappings -int ofArduino::convertDigitalPinToAnalog(size_t pin) const +int ofArduino::convertDigitalPinToAnalog(int pin) const { if (pin > analogPinMap.size()) { for (auto aPin : analogPinMap) diff --git a/libs/openFrameworks/communication/ofArduino.h b/libs/openFrameworks/communication/ofArduino.h index 2feb5e81f11..f47ac699d05 100644 --- a/libs/openFrameworks/communication/ofArduino.h +++ b/libs/openFrameworks/communication/ofArduino.h @@ -813,8 +813,8 @@ class ofArduino { bool isAnalogPin(int pin) const; bool isPin(int pin) const; - int convertAnalogPinToDigital(size_t pin) const; - int convertDigitalPinToAnalog(size_t pin) const; + int convertAnalogPinToDigital(int pin) const; + int convertDigitalPinToAnalog(int pin) const; }; typedef ofArduino ofStandardFirmata; diff --git a/libs/openFrameworks/communication/ofSerial.cpp b/libs/openFrameworks/communication/ofSerial.cpp index 5a76d972774..9e4fc096519 100644 --- a/libs/openFrameworks/communication/ofSerial.cpp +++ b/libs/openFrameworks/communication/ofSerial.cpp @@ -582,7 +582,7 @@ int ofSerial::readByte(){ #if defined( TARGET_OSX ) || defined( TARGET_LINUX ) - int nRead = read(fd, &tmpByte, 1); + ssize_t nRead = read(fd, &tmpByte, 1); if(nRead < 0){ if ( errno == EAGAIN ){ return OF_SERIAL_NO_DATA; diff --git a/libs/openFrameworks/graphics/ofImage.cpp b/libs/openFrameworks/graphics/ofImage.cpp index b6d85217730..af7450f8fa4 100644 --- a/libs/openFrameworks/graphics/ofImage.cpp +++ b/libs/openFrameworks/graphics/ofImage.cpp @@ -70,7 +70,7 @@ FIBITMAP* getBmpFromPixels(const ofPixels_ &pix){ FIBITMAP* bmp = FreeImage_AllocateT(freeImageType, width, height, bpp); unsigned char* bmpBits = FreeImage_GetBits(bmp); if(bmpBits != nullptr) { - int srcStride = width * pix.getBytesPerPixel(); + size_t srcStride = width * pix.getBytesPerPixel(); int dstStride = FreeImage_GetPitch(bmp); unsigned char* src = (unsigned char*) pixels; unsigned char* dst = bmpBits; @@ -190,7 +190,7 @@ static bool loadImage(ofPixels_ & pix, const std::filesystem::path& _ state.uri = &uri; if(uriParseUriA(&state, uriStr.c_str())!=URI_SUCCESS){ - const int bytesNeeded = 8 + 3 * strlen(uriStr.c_str()) + 1; + const size_t bytesNeeded = 8 + 3 * strlen(uriStr.c_str()) + 1; std::vector absUri(bytesNeeded); #ifdef TARGET_WIN32 uriWindowsFilenameToUriStringA(uriStr.c_str(), absUri.data()); diff --git a/libs/openFrameworks/math/ofMath.cpp b/libs/openFrameworks/math/ofMath.cpp index b8f00f321b9..45a02f317bf 100644 --- a/libs/openFrameworks/math/ofMath.cpp +++ b/libs/openFrameworks/math/ofMath.cpp @@ -12,9 +12,9 @@ using namespace std; //-------------------------------------------------- -int ofNextPow2(int a){ +unsigned long ofNextPow2(unsigned long a){ // from nehe.gamedev.net lesson 43 - int rval=1; + unsigned long rval=1; while(rvalchannels = channels; checkSizeAndChannelsConsistency("setNumChannels"); } @@ -243,15 +243,11 @@ void ofSoundBuffer::copyTo(float * outBuffer, std::size_t nFrames, std::size_t o } // do we have anything left? - int framesRemaining = nFrames - (int)nFramesToCopy; - if (framesRemaining > 0){ - if(!loop || size() == 0){ - // fill with 0s - for(std::size_t i = 0; i < framesRemaining * outChannels; i++){ - outBuffer[i] = 0; - } - }else{ - // loop + if(nFramesToCopy < nFrames) { + std::size_t framesRemaining = nFrames - nFramesToCopy; + if(!loop || size() == 0) { + std::fill_n(outBuffer, framesRemaining * outChannels, 0.0f); + } else { copyTo(outBuffer, framesRemaining, outChannels, 0, loop); } } @@ -294,8 +290,8 @@ void ofSoundBuffer::addTo(float * outBuffer, std::size_t nFrames, std::size_t ou } // do we have anything left? - int framesRemaining = nFrames - (int)nFramesToCopy; - if (framesRemaining > 0 && loop){ + if (nFrames > nFramesToCopy && loop){ + std::size_t framesRemaining = nFrames - nFramesToCopy; // loop addTo(outBuffer, framesRemaining, outChannels, 0, loop); } diff --git a/libs/openFrameworks/sound/ofSoundBuffer.h b/libs/openFrameworks/sound/ofSoundBuffer.h index 22a74e2c515..e305492907f 100644 --- a/libs/openFrameworks/sound/ofSoundBuffer.h +++ b/libs/openFrameworks/sound/ofSoundBuffer.h @@ -102,7 +102,7 @@ class ofSoundBuffer { /// the number of channels per frame std::size_t getNumChannels() const { return channels; } /// set the number of channels. does not change the underlying data, ie causes getNumFrames() to return a different result. - void setNumChannels(int channels); + void setNumChannels(std::size_t channels); /// the number of frames, ie the number of sets of (getNumChannels()) samples std::size_t getNumFrames() const { return size()/getNumChannels(); } diff --git a/libs/openFrameworks/video/ofAVFoundationGrabber.h b/libs/openFrameworks/video/ofAVFoundationGrabber.h index 1ace79c78a7..8f061655314 100644 --- a/libs/openFrameworks/video/ofAVFoundationGrabber.h +++ b/libs/openFrameworks/video/ofAVFoundationGrabber.h @@ -33,7 +33,7 @@ class ofAVFoundationGrabber; int height; BOOL bInitCalled; - int deviceID; + NSUInteger deviceID; AVCaptureDeviceInput *captureInput; AVCaptureVideoDataOutput *captureOutput;