usb_webcam: Fix warnings and enable Werror

Done as part of #9460

Change-Id: I45f53451c91d63f5e5170234c75a831472cfffc7
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4501
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
Franck LeCodeur
2021-10-18 16:28:20 +00:00
committed by Adrien Destugues
parent 5b38b945ae
commit 628ddb2790
9 changed files with 44 additions and 39 deletions
+1 -1
View File
@@ -713,7 +713,7 @@ rule ArchitectureSetupWarnings architecture
EnableWerror src add-ons media media-add-ons reader ; EnableWerror src add-ons media media-add-ons reader ;
EnableWerror src add-ons media media-add-ons tone_producer_demo ; EnableWerror src add-ons media media-add-ons tone_producer_demo ;
EnableWerror src add-ons media media-add-ons usb_vision ; EnableWerror src add-ons media media-add-ons usb_vision ;
# EnableWerror src add-ons media media-add-ons usb_webcam ; EnableWerror src add-ons media media-add-ons usb_webcam ;
EnableWerror src add-ons media media-add-ons video_mixer ; EnableWerror src add-ons media media-add-ons video_mixer ;
EnableWerror src add-ons media media-add-ons video_producer_demo ; EnableWerror src add-ons media media-add-ons video_producer_demo ;
EnableWerror src add-ons media media-add-ons videowindow ; EnableWerror src add-ons media media-add-ons videowindow ;
@@ -175,8 +175,8 @@ WebCamMediaAddOn::CameraRemoved(CamDevice* device)
void void
WebCamMediaAddOn::FillDefaultFlavorInfo(flavor_info* info) WebCamMediaAddOn::FillDefaultFlavorInfo(flavor_info* info)
{ {
info->name = "USB Web Camera"; info->name = (char *)"USB Web Camera";
info->info = "USB Web Camera"; info->info = (char *)"USB Web Camera";
info->kinds = B_BUFFER_PRODUCER | B_CONTROLLABLE | B_PHYSICAL_INPUT; info->kinds = B_BUFFER_PRODUCER | B_CONTROLLABLE | B_PHYSICAL_INPUT;
info->flavor_flags = 0;//B_FLAVOR_IS_GLOBAL; info->flavor_flags = 0;//B_FLAVOR_IS_GLOBAL;
info->internal_id = atomic_add((int32*)&fInternalIDCounter, 1); info->internal_id = atomic_add((int32*)&fInternalIDCounter, 1);
@@ -571,8 +571,6 @@ CamDevice::DataPumpThread()
for (int i = 0; i<numPacketDescriptors; i++) for (int i = 0; i<numPacketDescriptors; i++)
packetDescriptors[i].request_length = 256; packetDescriptors[i].request_length = 256;
int fullPackets = 0;
int totalPackets = 0;
while (fTransferEnabled) { while (fTransferEnabled) {
ssize_t len = -1; ssize_t len = -1;
BAutolock lock(fLocker); BAutolock lock(fLocker);
@@ -78,9 +78,9 @@ CamSensor::AcceptVideoFrame(uint32 &width, uint32 &height)
width = MaxWidth(); width = MaxWidth();
if (height < 1) if (height < 1)
height = MaxHeight(); height = MaxHeight();
if (width > MaxWidth()) if (width > (uint32)MaxWidth())
width = MaxWidth(); width = MaxWidth();
if (height > MaxHeight()) if (height > (uint32)MaxHeight())
height = MaxHeight(); height = MaxHeight();
return B_OK; return B_OK;
} }
@@ -130,7 +130,7 @@ status_t
CamSensor::ProbeByIICSignature(const uint8 *regList, const uint8 *matchList, CamSensor::ProbeByIICSignature(const uint8 *regList, const uint8 *matchList,
size_t count) size_t count)
{ {
for (int i = 0; i < count; i++) { for (size_t i = 0; i < count; i++) {
uint8 value = 0; uint8 value = 0;
ssize_t len; ssize_t len;
len = Device()->ReadIIC8(regList[i], &value); len = Device()->ReadIIC8(regList[i], &value);
@@ -67,12 +67,16 @@ CamStreamingDeframer::Write(const void *buffer, size_t size)
end = bufsize; end = bufsize;
} }
// whole buffer belongs to a frame, simple // whole buffer belongs to a frame, simple
if ((fState == ST_FRAME) && (fCurrentFrame->Position() + bufsize < fMinFrameSize)) { if (fState == ST_FRAME) {
// no residual data, and off_t position = fCurrentFrame->Position();
fCurrentFrame->Write(buf, bufsize); if (position + bufsize < 0
fInputBuff.Seek(0LL, SEEK_SET); || (size_t)(position + bufsize) < fMinFrameSize) {
fInputBuff.SetSize(0); // no residual data, and
return size; fCurrentFrame->Write(buf, bufsize);
fInputBuff.Seek(0LL, SEEK_SET);
fInputBuff.SetSize(0);
return size;
}
} }
// waiting for a frame... // waiting for a frame...
@@ -116,10 +120,13 @@ CamStreamingDeframer::Write(const void *buffer, size_t size)
#endif #endif
#if 1 #if 1
i = 0; i = 0;
if (fCurrentFrame->Position() < fMinFrameSize) { off_t currentFramePosition = fCurrentFrame->Position();
if (fCurrentFrame->Position() + bufsize >= fMinFrameSize) if (currentFramePosition < 0
|| (size_t)currentFramePosition < fMinFrameSize) {
if (currentFramePosition + bufsize > 0
&& (size_t)(currentFramePosition + bufsize) >= fMinFrameSize) {
i = (fMinFrameSize - (size_t)fCurrentFrame->Position()); i = (fMinFrameSize - (size_t)fCurrentFrame->Position());
else } else
i = bufsize; i = bufsize;
} }
PRINT((CH ": checking for EOF; bufsize=%d i=%d" CT, bufsize, i)); PRINT((CH ": checking for EOF; bufsize=%d i=%d" CT, bufsize, i));
@@ -133,7 +140,9 @@ CamStreamingDeframer::Write(const void *buffer, size_t size)
i += j; i += j;
PRINT((CH "| EOF[%d] at offset %d; pos %" B_PRIdOFF CT, PRINT((CH "| EOF[%d] at offset %d; pos %" B_PRIdOFF CT,
which, i, fCurrentFrame->Position())); which, i, fCurrentFrame->Position()));
if (fCurrentFrame->Position()+i >= fMaxFrameSize) { off_t position = fCurrentFrame->Position();
if (position + i >= 0
&& (size_t)(position + i) >= fMaxFrameSize) {
// too big: discard // too big: discard
//i = -1; //i = -1;
discard = true; discard = true;
@@ -159,7 +168,9 @@ CamStreamingDeframer::Write(const void *buffer, size_t size)
PRINT((CH ": writing %d bytes" CT, end)); PRINT((CH ": writing %d bytes" CT, end));
if (end <= bufsize) if (end <= bufsize)
fCurrentFrame->Write(buf, end); fCurrentFrame->Write(buf, end);
if (fCurrentFrame->Position() > fMaxFrameSize) { off_t currentPosition = fCurrentFrame->Position();
if (currentPosition > 0
&& (size_t)currentPosition > fMaxFrameSize) {
fCurrentFrame->SetSize(fMaxFrameSize); fCurrentFrame->SetSize(fMaxFrameSize);
detach = true; detach = true;
} }
@@ -711,7 +711,7 @@ VideoProducer::GetParameterValue(
*((uint32 *)value) = fColor; *((uint32 *)value) = fColor;
return B_OK; return B_OK;
case P_INFO: case P_INFO:
if (*size < fInfoString.Length() + 1) if (*size < (size_t)(fInfoString.Length() + 1))
return EINVAL; return EINVAL;
*last_change = fLastColorChange; *last_change = fLastColorChange;
*size = fInfoString.Length() + 1; *size = fInfoString.Length() + 1;
@@ -27,7 +27,7 @@ const usb_webcam_support_descriptor kSupportedDevices[] = {
}; };
#warning TODO! // TODO: Complete implementation!
// datasheets: (scarce) // datasheets: (scarce)
// http://www.digchip.com/datasheets/parts/datasheet/132/NW800.php // http://www.digchip.com/datasheets/parts/datasheet/132/NW800.php
@@ -88,10 +88,7 @@ NW80xCamDevice::SupportsIsochronous()
status_t status_t
NW80xCamDevice::StartTransfer() NW80xCamDevice::StartTransfer()
{ {
status_t err;
uint8 r;
SetScale(1); SetScale(1);
if (Sensor()) if (Sensor())
SetVideoFrame(BRect(0, 0, Sensor()->MaxWidth()-1, Sensor()->MaxHeight()-1)); SetVideoFrame(BRect(0, 0, Sensor()->MaxWidth()-1, Sensor()->MaxHeight()-1));
@@ -100,6 +97,9 @@ NW80xCamDevice::StartTransfer()
DumpRegs(); DumpRegs();
#if 0 #if 0
status_t err;
uint8 r;
err = ReadReg(SN9C102_CHIP_CTRL, &r, 1, true); err = ReadReg(SN9C102_CHIP_CTRL, &r, 1, true);
if (err < 0) if (err < 0)
return err; return err;
@@ -116,11 +116,11 @@ status_t
NW80xCamDevice::StopTransfer() NW80xCamDevice::StopTransfer()
{ {
status_t err; status_t err;
uint8 r; DumpRegs();
DumpRegs();
err = CamDevice::StopTransfer(); err = CamDevice::StopTransfer();
#if 0 #if 0
uint8 r;
// if (err < 0) // if (err < 0)
// return err; // return err;
err = ReadReg(SN9C102_CHIP_CTRL, &r, 1, true); err = ReadReg(SN9C102_CHIP_CTRL, &r, 1, true);
@@ -158,7 +158,7 @@ NW80xCamDevice::GetStatusIIC()
{ {
status_t err = B_ERROR; status_t err = B_ERROR;
uint8 status = 0; uint8 status = 0;
#warning WRITEME // TODO: WRITEME
//dprintf(ID "i2c_status: error 0x%08lx, status = %02x\n", err, status); //dprintf(ID "i2c_status: error 0x%08lx, status = %02x\n", err, status);
if (err < 0) if (err < 0)
return err; return err;
@@ -169,8 +169,7 @@ NW80xCamDevice::GetStatusIIC()
status_t status_t
NW80xCamDevice::WaitReadyIIC() NW80xCamDevice::WaitReadyIIC()
{ {
status_t err; // TODO: WRITEME
#warning WRITEME
return EBUSY; return EBUSY;
} }
@@ -178,8 +177,7 @@ NW80xCamDevice::WaitReadyIIC()
ssize_t ssize_t
NW80xCamDevice::WriteIIC(uint8 address, uint8 *data, size_t count) NW80xCamDevice::WriteIIC(uint8 address, uint8 *data, size_t count)
{ {
status_t err; size_t i;
int i;
uint8 buffer[0x23]; uint8 buffer[0x23];
if (count > 16) if (count > 16)
return EINVAL; return EINVAL;
@@ -206,7 +204,6 @@ ssize_t
NW80xCamDevice::ReadIIC8(uint8 address, uint8 *data) NW80xCamDevice::ReadIIC8(uint8 address, uint8 *data)
{ {
status_t err; status_t err;
int i;
uint8 buffer[0x23]; uint8 buffer[0x23];
memset(buffer, 0, sizeof(buffer)); memset(buffer, 0, sizeof(buffer));
buffer[0x20] = Sensor() ? Sensor()->IICReadAddress() : 0; buffer[0x20] = Sensor() ? Sensor()->IICReadAddress() : 0;
@@ -234,7 +231,6 @@ ssize_t
NW80xCamDevice::ReadIIC16(uint8 address, uint16 *data) NW80xCamDevice::ReadIIC16(uint8 address, uint16 *data)
{ {
status_t err; status_t err;
int i;
uint8 buffer[0x23]; uint8 buffer[0x23];
memset(buffer, 0, sizeof(buffer)); memset(buffer, 0, sizeof(buffer));
buffer[0x20] = Sensor() ? Sensor()->IICReadAddress() : 0; buffer[0x20] = Sensor() ? Sensor()->IICReadAddress() : 0;
@@ -123,7 +123,7 @@ QuickCamDevice::GetStatusIIC()
{ {
status_t err = B_ERROR; status_t err = B_ERROR;
uint8 status = 0; uint8 status = 0;
#warning WRITEME // TODO: WRITEME
//dprintf(ID "i2c_status: error 0x%08lx, status = %02x\n", err, status); //dprintf(ID "i2c_status: error 0x%08lx, status = %02x\n", err, status);
if (err < 0) if (err < 0)
return err; return err;
@@ -134,7 +134,7 @@ QuickCamDevice::GetStatusIIC()
status_t status_t
QuickCamDevice::WaitReadyIIC() QuickCamDevice::WaitReadyIIC()
{ {
#warning WRITEME // TODO: WRITEME
return EBUSY; return EBUSY;
} }
@@ -142,7 +142,7 @@ QuickCamDevice::WaitReadyIIC()
ssize_t ssize_t
QuickCamDevice::WriteIIC(uint8 address, uint8 *data, size_t count) QuickCamDevice::WriteIIC(uint8 address, uint8 *data, size_t count)
{ {
int i; size_t i;
uint8 buffer[0x23]; uint8 buffer[0x23];
if (count > 16) if (count > 16)
return EINVAL; return EINVAL;
@@ -170,10 +170,10 @@ TAS5110C1BSensor::SetVideoFrame(BRect rect)
void void
TAS5110C1BSensor::AddParameters(BParameterGroup *group, int32 &index) TAS5110C1BSensor::AddParameters(BParameterGroup *group, int32 &index)
{ {
BContinuousParameter *p;
CamSensor::AddParameters(group, index); CamSensor::AddParameters(group, index);
#ifdef ENABLE_GAIN #ifdef ENABLE_GAIN
BContinuousParameter *p;
// NON-FUNCTIONAL // NON-FUNCTIONAL
BParameterGroup *g = group->MakeGroup("global gain"); BParameterGroup *g = group->MakeGroup("global gain");
p = g->MakeContinuousParameter(index++, p = g->MakeContinuousParameter(index++,