mirror of https://github.com/EspoTek/Labrador.git
Fix a few compiler warnings (#189)
* Fix unused variable warnings * Fix misleading indent warning * Fix potential buffer overflow with fgets() Was reading 256 bytes into a 255-byte array. The function would read at most 255 bytes then try to append a nul (which would overflow), now will read at most 254 bytes before appending the nul. * Move isoCallback() from .h to .cpp file Fixes warnings that the function is unused by every other file that includes unixusbdriver.h.
This commit is contained in:
parent
fb04347852
commit
682d49dc13
|
@ -40,7 +40,7 @@ float *isoBuffer_file::readBuffer(double sampleWindow, int numSamples, bool sing
|
||||||
qDebug() << "back" << back;
|
qDebug() << "back" << back;
|
||||||
qDebug() << "front" << front;
|
qDebug() << "front" << front;
|
||||||
*/
|
*/
|
||||||
int idx, subIdx;
|
int idx;
|
||||||
if(readData!=NULL) free(readData);
|
if(readData!=NULL) free(readData);
|
||||||
readData = (float *) calloc(numSamples, sizeof(float));
|
readData = (float *) calloc(numSamples, sizeof(float));
|
||||||
|
|
||||||
|
|
|
@ -862,8 +862,8 @@ void isoDriver::multimeterAction(){
|
||||||
|
|
||||||
if(singleShotEnabled && (triggerDelay != 0))
|
if(singleShotEnabled && (triggerDelay != 0))
|
||||||
singleShotTriggered(1);
|
singleShotTriggered(1);
|
||||||
|
|
||||||
readData375_CH1 = internalBuffer375_CH1->readBuffer(display.window,GRAPH_SAMPLES, false, display.delay + triggerDelay);
|
readData375_CH1 = internalBuffer375_CH1->readBuffer(display.window,GRAPH_SAMPLES, false, display.delay + triggerDelay);
|
||||||
|
|
||||||
QVector<double> x(GRAPH_SAMPLES), CH1(GRAPH_SAMPLES);
|
QVector<double> x(GRAPH_SAMPLES), CH1(GRAPH_SAMPLES);
|
||||||
analogConvert(readData375_CH1.get(), &CH1, 2048, 0, 1); //No AC coupling!
|
analogConvert(readData375_CH1.get(), &CH1, 2048, 0, 1); //No AC coupling!
|
||||||
|
|
|
@ -49,7 +49,7 @@ void espoComboBox::readWaveformList(void)
|
||||||
qFatal("Could not load _list.wfl");
|
qFatal("Could not load _list.wfl");
|
||||||
}
|
}
|
||||||
|
|
||||||
while (fgets(nameBuffer,256,listPtr) !=NULL){
|
while (fgets(nameBuffer, sizeof(nameBuffer), listPtr) != NULL){
|
||||||
qDebug() << "nameBuffer = " << nameBuffer;
|
qDebug() << "nameBuffer = " << nameBuffer;
|
||||||
strtok(nameBuffer, "\n\r");
|
strtok(nameBuffer, "\n\r");
|
||||||
newNames->append(nameBuffer);
|
newNames->append(nameBuffer);
|
||||||
|
|
|
@ -70,7 +70,7 @@ void espoSlider::rearrange(){
|
||||||
int k = 7;
|
int k = 7;
|
||||||
int c = 5;
|
int c = 5;
|
||||||
|
|
||||||
int left = this->geometry().left();
|
//int left = this->geometry().left();
|
||||||
int right = this->geometry().right();
|
int right = this->geometry().right();
|
||||||
int top = this->geometry().top();
|
int top = this->geometry().top();
|
||||||
int bottom = this->geometry().bottom();
|
int bottom = this->geometry().bottom();
|
||||||
|
|
|
@ -8,7 +8,6 @@ siprint::siprint(const char *unitsInit, double valInit)
|
||||||
|
|
||||||
char* siprint::printVal(){
|
char* siprint::printVal(){
|
||||||
std::string suffix;
|
std::string suffix;
|
||||||
double modifiedValue;
|
|
||||||
bool negative = (value < 0);
|
bool negative = (value < 0);
|
||||||
|
|
||||||
char* tempStringPtr = printString;
|
char* tempStringPtr = printString;
|
||||||
|
|
|
@ -123,6 +123,24 @@ void unixUsbDriver::usbSendControl(uint8_t RequestType, uint8_t Request, uint16_
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Callback on iso transfer complete.
|
||||||
|
static void LIBUSB_CALL isoCallback(struct libusb_transfer * transfer){
|
||||||
|
tcBlockMutex.lock();
|
||||||
|
//int number = ((tcBlock *)transfer->user_data)->number;
|
||||||
|
//bool completed = ((tcBlock *)transfer->user_data)->completed;
|
||||||
|
|
||||||
|
//qDebug() << "CALLBACK" << number;
|
||||||
|
//qDebug() << completed;
|
||||||
|
|
||||||
|
if(transfer->status!=LIBUSB_TRANSFER_CANCELLED){
|
||||||
|
((tcBlock *)transfer->user_data)->completed = true;
|
||||||
|
((tcBlock *)transfer->user_data)->timeReceived = QDateTime::currentMSecsSinceEpoch();
|
||||||
|
}
|
||||||
|
//qDebug() << ((tcBlock *)transfer->user_data)->timeReceived;
|
||||||
|
tcBlockMutex.unlock();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int unixUsbDriver::usbIsoInit(void){
|
int unixUsbDriver::usbIsoInit(void){
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
|
|
|
@ -95,22 +95,4 @@ public slots:
|
||||||
void backupCleanup(void);
|
void backupCleanup(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
//Callback on iso transfer complete.
|
|
||||||
static void LIBUSB_CALL isoCallback(struct libusb_transfer * transfer){
|
|
||||||
tcBlockMutex.lock();
|
|
||||||
//int number = ((tcBlock *)transfer->user_data)->number;
|
|
||||||
//bool completed = ((tcBlock *)transfer->user_data)->completed;
|
|
||||||
|
|
||||||
//qDebug() << "CALLBACK" << number;
|
|
||||||
//qDebug() << completed;
|
|
||||||
|
|
||||||
if(transfer->status!=LIBUSB_TRANSFER_CANCELLED){
|
|
||||||
((tcBlock *)transfer->user_data)->completed = true;
|
|
||||||
((tcBlock *)transfer->user_data)->timeReceived = QDateTime::currentMSecsSinceEpoch();
|
|
||||||
}
|
|
||||||
//qDebug() << ((tcBlock *)transfer->user_data)->timeReceived;
|
|
||||||
tcBlockMutex.unlock();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // unixUsbDriver_H
|
#endif // unixUsbDriver_H
|
||||||
|
|
Loading…
Reference in New Issue