Message ID | 20190319113532.18400-1-kieran.bingham@ideasonboard.com |
---|---|
State | Accepted |
Commit | 18647a532483470d9f64bc6cb1bbeeda39c2670d |
Headers | show |
Series |
|
Related | show |
Hi Kieran, Thank you for the patch. I'd rename the subject to "Fix uninitialized variable warning" or something similar. On Tue, Mar 19, 2019 at 11:35:32AM +0000, Kieran Bingham wrote: > The local variable ifaceId generates a compiler warning that it is used > without initialisation. Could you specify the compiler version ? > The loop, and check against the loop iterator, and the > topology.num_interfaces actually ensures that this isn't the case, and > that ifaceId can only be used when set to a valid ID. > > The media_v2_interface.id field documents the ID as simply "Unique ID > for the interface" but does not specify if zero is a valid ID or not. As > such we don't further check the pre-initialised ID for validity and keep > the existing check on the iterator count to determine if the ID had been > discovered successfully. I think we could still change that as the kernel ensures that entity IDs start at 1, but I'll leave that up to you. > Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> With the above fixed, Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > --- > src/libcamera/media_device.cpp | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp > index ea4608932834..1e9024bf9721 100644 > --- a/src/libcamera/media_device.cpp > +++ b/src/libcamera/media_device.cpp > @@ -516,7 +516,7 @@ struct media_v2_interface *MediaDevice::findInterface(const struct media_v2_topo > { > struct media_v2_link *links = reinterpret_cast<struct media_v2_link *> > (topology.ptr_links); > - unsigned int ifaceId; > + unsigned int ifaceId = 0; > unsigned int i; > > for (i = 0; i < topology.num_links; ++i) {
diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp index ea4608932834..1e9024bf9721 100644 --- a/src/libcamera/media_device.cpp +++ b/src/libcamera/media_device.cpp @@ -516,7 +516,7 @@ struct media_v2_interface *MediaDevice::findInterface(const struct media_v2_topo { struct media_v2_link *links = reinterpret_cast<struct media_v2_link *> (topology.ptr_links); - unsigned int ifaceId; + unsigned int ifaceId = 0; unsigned int i; for (i = 0; i < topology.num_links; ++i) {
The local variable ifaceId generates a compiler warning that it is used without initialisation. The loop, and check against the loop iterator, and the topology.num_interfaces actually ensures that this isn't the case, and that ifaceId can only be used when set to a valid ID. The media_v2_interface.id field documents the ID as simply "Unique ID for the interface" but does not specify if zero is a valid ID or not. As such we don't further check the pre-initialised ID for validity and keep the existing check on the iterator count to determine if the ID had been discovered successfully. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> --- src/libcamera/media_device.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)