[QCAP] Final patch

Maarten Lankhorst m.b.lankhorst at gmail.com
Fri May 20 05:26:12 CDT 2005


Dimi Paun wrote:

>On Fri, 2005-05-20 at 00:42 +0200, Maarten Lankhorst wrote:
>  
>
>>m3h, v4l driver for vfwcapture.. please leave the ERR notice on 
>>initialisation intact, thank you :)
>>    
>>
>
>I think you've overusing ERR(). ERR() should be called
>to signal an internal error such as inconsistent state,
>not something that the function is designed to handle.
>
>  
>
What do you suggest then ... fprintf(stderr?

>>+            capBox->grab_buf = CoTaskMemAlloc(sizeof(struct video_mmap) * capBox->buffers);
>>+            if(!capBox->grab_buf) {
>>+                ERR("Out of memory?\n");
>>+                munmap(capBox->pmap, capBox->gb_buffers.size);
>>+                return E_OUTOFMEMORY;
>>+            }
>>    
>>
>
>The function knows how to deal with this condition gracefully,
>just get rid of the ERR().
>
>
>  
>
>>+         if (!capBox->grab_data)
>>+         {
>>+            ERR("%p: Out of memory?\n", capBox);
>>+            return E_OUTOFMEMORY;
>>+         }
>>    
>>
>
>Ditto. Also the code is more clear if you just do:
>            if (!capBox->grab_data) return E_OUTOFMEMORY;
>
>  
>
>>+   if (!capBox) {
>>+      ERR("Out of memory\n");
>>+      return E_OUTOFMEMORY;
>>+   }
>>    
>>
>
>Ditto.
>
>  
>
Ok,  I'll remove the out of memory errors.

>>+   if (stat (device, &st) == -1) {
>>+      ERR("%s: %s\n", device, strerror(errno));
>>+      CoTaskMemFree(capBox);
>>+      return E_FAIL;
>>+   }
>>    
>>
>
>Why is this a ERR()?
>
>  
>
>>+
>>+   if (!S_ISCHR (st.st_mode)) {
>>+      ERR("%s: Not a device\n", device);
>>+      CoTaskMemFree(capBox);
>>+      return E_FAIL;
>>+   }
>>    
>>
>
>And why this? 
>  
>
>>+
>>+   capBox->fd = open(device, O_RDWR | O_NONBLOCK);
>>+   if (capBox->fd == -1) {
>>+      ERR("%s: Failed to open: %s\n", device, strerror(errno));
>>+      CoTaskMemFree(capBox);
>>+      return E_FAIL;
>>+   }
>>    
>>
>
>This is a TRACE or WARN at most.
>
>  
>
Basically, I made those an error because before getting to this point, 
the device has existed (It gets detected by devenum using 
avicap32->getdriverdescription, if something is wrong now, it will be 
much clearer why it happened, I don't believe most people that are going 
to use this webcam patch will be able to find out what happened 
themself, so I tried being as verbose as possible, especially since MSN 
will tell NOTHING, and most people wil be guessing in the dark. There's 
a small bug in our devenum, which causes it not to rescan for devices. 
The NATIVE version does, and since that gets installed by internet 
explorer, it's used. In that case, most of the errors I described 
shouldn't happen, because if it happens, something REALLY weird is going 
on... avicap runs the same stuff and works fine, but in qcap it fails... 
sounds like an 'inconsistent state' to me........ but who am I to tell O_O

>>+      ERR("Tinkerer detected? Thou shalt not define HAVE_V4L2\n");
>>+      CoTaskMemFree(capBox);
>>+      close(capBox->fd);
>>+      return E_FAIL;
>>    
>>
>
>This is a FIXME.
>
>And so on...
>  
>
Fine :/



More information about the wine-devel mailing list