[Bug 487] New: ComediSubDeviceAOut crashes if comedi device not found.

For more infomation about this bug, visit
Summary: ComediSubDeviceAOut crashes if comedi device not found.
Product: OCL
Version: trunk
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: Hardware
AssignedTo: orocos-dev [..] ...
ReportedBy: peter [dot] soetens [..] ...
CC: orocos-dev [..] ...
Estimated Hours: 0.0

In case the comedi device (like /dev/comedi0) has not yet been configured, this
class will crash/segfault or even cause a kernel oops (under RTAI) because it
does not check the validity of the device. ComediSubDeviceAIn most likely has
the same behaviour. The ComediSubDeviceD* classes work fine.

[Bug 487] ComediSubDeviceAOut crashes if comedi device not found

For more infomation about this bug, visit

Peter Soetens
<peter [dot] soetens [..] ...> changed:

What |Removed |Added
--------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED

--- Comment #4 from Peter Soetens
<peter [dot] soetens [..] ...> 2008-02-08 16:00:17 ---
Yes, it's really fixed.

[Bug 487] ComediSubDeviceAOut crashes if comedi device not found

For more infomation about this bug, visit

Peter Soetens
<peter [dot] soetens [..] ...> changed:

What |Removed |Added
--------------------------------------------------------------------------
Status|ASSIGNED |NEW
AssignedTo|peter [dot] soetens [..] ... |orocos-
| |dev [..] ...

--- Comment #3 from Peter Soetens
<peter [dot] soetens [..] ...> 2008-02-08 15:59:24 ---
$ svn ci -m"Fix bug #487: ComediSubDeviceAOut crashes if comedi device not
found."
Sending comedi/dev/ComediSubDeviceAIn.cpp
Sending comedi/dev/ComediSubDeviceAOut.cpp
Transmitting file data ..
Committed revision 28932.

About Klaas' remark: throwing an exception is not very user friendly, although
it stops the application, but your mileage may vary.

What such a device driver layer (like Comedi) really needs is a 'factory'
function which returns a subdevice object for you to use. If the (sub)device
can not be used, plain null is returned, which may also be user unfriendly if
said return value is never checked... but that's not a discussion for this bug
:-)

Anyway, this patch at least fixes evil crashes in such cases.

[Bug 487] ComediSubDeviceAOut crashes if comedi device not found

For more infomation about this bug, visit

Klaas Gadeyne <klaas [dot] gadeyne [..] ...> changed:

What |Removed |Added
--------------------------------------------------------------------------
CC| |klaas [dot] gadeyne [..] ...

--- Comment #2 from Klaas Gadeyne <klaas [dot] gadeyne [..] ...> 2008-02-05 20:05:18 ---
(In reply to comment #1)
> Created an attachment (id=230)
--> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=230) [details]
> Fixes Comedi Analog In/Out subdevices
>
> Works for me(tm).

Patch looks ok. Is there any reason why you didn't throw an exception in the
constructor instead of this approach?
For sure, to me the code in this file does not meet OCL guidelines, but that
doesn't belong in this bugreport

[Bug 487] ComediSubDeviceAOut crashes if comedi device not found

For more infomation about this bug, visit

Peter Soetens
<peter [dot] soetens [..] ...> changed:

What |Removed |Added
--------------------------------------------------------------------------
Status|NEW |ASSIGNED
AssignedTo|orocos- |peter [dot] soetens [..] ...
|dev [..] ... |

--- Comment #1 from Peter Soetens
<peter [dot] soetens [..] ...> 2008-02-05 10:17:22 ---
Created an attachment (id=230)
--> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=230)
Fixes Comedi Analog In/Out subdevices

Works for me(tm).