[libcamera-devel] libcamera: media_object: Rename major/minor functions

Message ID 20190107170902.13618-1-kieran.bingham@ideasonboard.com
State Accepted
Headers show
Series
  • [libcamera-devel] libcamera: media_object: Rename major/minor functions
Related show

Commit Message

Kieran Bingham Jan. 7, 2019, 5:09 p.m. UTC
The system libraries define macro's for major/minor through
<sys/types.h> on some versions of GCC/GLibc.

To prevent namespace collisions with these macros, rename our major and
minor device node accessors.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 src/libcamera/device_enumerator.cpp  | 4 ++--
 src/libcamera/include/media_object.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

Comments

Laurent Pinchart Jan. 7, 2019, 7:32 p.m. UTC | #1
Hi Kieran,

Thank you for the patch.

On Monday, 7 January 2019 19:09:02 EET Kieran Bingham wrote:
> The system libraries define macro's for major/minor through
> <sys/types.h> on some versions of GCC/GLibc.
> 
> To prevent namespace collisions with these macros, rename our major and
> minor device node accessors.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> ---
>  src/libcamera/device_enumerator.cpp  | 4 ++--
>  src/libcamera/include/media_object.h | 4 ++--

No documentation update ? Apart from that,

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/src/libcamera/device_enumerator.cpp
> b/src/libcamera/device_enumerator.cpp index 7ad1c501ff3d..c088f3e5d243
> 100644
> --- a/src/libcamera/device_enumerator.cpp
> +++ b/src/libcamera/device_enumerator.cpp
> @@ -208,10 +208,10 @@ int DeviceEnumerator::addDevice(const std::string
> &devnode)
> 
>  	/* Associate entities to device node paths. */
>  	for (MediaEntity *entity : media->entities()) {
> -		if (entity->major() == 0 && entity->minor() == 0)
> +		if (entity->deviceMajor() == 0 && entity->deviceMinor() == 0)
>  			continue;
> 
> -		std::string devnode = lookupDevnode(entity->major(), entity->minor());
> +		std::string devnode = lookupDevnode(entity->deviceMajor(),
> entity->deviceMinor());
>  		if (devnode.empty())
>  			return -EINVAL;
> 
> diff --git a/src/libcamera/include/media_object.h
> b/src/libcamera/include/media_object.h index 950a33286690..04b9a8909465
> 100644
> --- a/src/libcamera/include/media_object.h
> +++ b/src/libcamera/include/media_object.h
> @@ -80,8 +80,8 @@ class MediaEntity : public MediaObject
>  {
>  public:
>  	const std::string &name() const { return name_; }
> -	unsigned int major() const { return major_; }
> -	unsigned int minor() const { return minor_; }
> +	unsigned int deviceMajor() const { return major_; }
> +	unsigned int deviceMinor() const { return minor_; }
> 
>  	const std::vector<MediaPad *> &pads() const { return pads_; }
Kieran Bingham Jan. 8, 2019, 10:53 a.m. UTC | #2
Hi Laurent,

On 07/01/2019 19:32, Laurent Pinchart wrote:
> Hi Kieran,
> 
> Thank you for the patch.
> 
> On Monday, 7 January 2019 19:09:02 EET Kieran Bingham wrote:
>> The system libraries define macro's for major/minor through
>> <sys/types.h> on some versions of GCC/GLibc.
>>
>> To prevent namespace collisions with these macros, rename our major and
>> minor device node accessors.
>>
>> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
>> ---
>>  src/libcamera/device_enumerator.cpp  | 4 ++--
>>  src/libcamera/include/media_object.h | 4 ++--
> 
> No documentation update ? Apart from that,
> 

Ugh ... that's what happens when the documentation is away from the code :-(

I'll respin a v2 (/3?)

> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
>>  2 files changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/src/libcamera/device_enumerator.cpp
>> b/src/libcamera/device_enumerator.cpp index 7ad1c501ff3d..c088f3e5d243
>> 100644
>> --- a/src/libcamera/device_enumerator.cpp
>> +++ b/src/libcamera/device_enumerator.cpp
>> @@ -208,10 +208,10 @@ int DeviceEnumerator::addDevice(const std::string
>> &devnode)
>>
>>  	/* Associate entities to device node paths. */
>>  	for (MediaEntity *entity : media->entities()) {
>> -		if (entity->major() == 0 && entity->minor() == 0)
>> +		if (entity->deviceMajor() == 0 && entity->deviceMinor() == 0)
>>  			continue;
>>
>> -		std::string devnode = lookupDevnode(entity->major(), entity->minor());
>> +		std::string devnode = lookupDevnode(entity->deviceMajor(),
>> entity->deviceMinor());
>>  		if (devnode.empty())
>>  			return -EINVAL;
>>
>> diff --git a/src/libcamera/include/media_object.h
>> b/src/libcamera/include/media_object.h index 950a33286690..04b9a8909465
>> 100644
>> --- a/src/libcamera/include/media_object.h
>> +++ b/src/libcamera/include/media_object.h
>> @@ -80,8 +80,8 @@ class MediaEntity : public MediaObject
>>  {
>>  public:
>>  	const std::string &name() const { return name_; }
>> -	unsigned int major() const { return major_; }
>> -	unsigned int minor() const { return minor_; }
>> +	unsigned int deviceMajor() const { return major_; }
>> +	unsigned int deviceMinor() const { return minor_; }
>>
>>  	const std::vector<MediaPad *> &pads() const { return pads_; }
>

Patch

diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp
index 7ad1c501ff3d..c088f3e5d243 100644
--- a/src/libcamera/device_enumerator.cpp
+++ b/src/libcamera/device_enumerator.cpp
@@ -208,10 +208,10 @@  int DeviceEnumerator::addDevice(const std::string &devnode)
 
 	/* Associate entities to device node paths. */
 	for (MediaEntity *entity : media->entities()) {
-		if (entity->major() == 0 && entity->minor() == 0)
+		if (entity->deviceMajor() == 0 && entity->deviceMinor() == 0)
 			continue;
 
-		std::string devnode = lookupDevnode(entity->major(), entity->minor());
+		std::string devnode = lookupDevnode(entity->deviceMajor(), entity->deviceMinor());
 		if (devnode.empty())
 			return -EINVAL;
 
diff --git a/src/libcamera/include/media_object.h b/src/libcamera/include/media_object.h
index 950a33286690..04b9a8909465 100644
--- a/src/libcamera/include/media_object.h
+++ b/src/libcamera/include/media_object.h
@@ -80,8 +80,8 @@  class MediaEntity : public MediaObject
 {
 public:
 	const std::string &name() const { return name_; }
-	unsigned int major() const { return major_; }
-	unsigned int minor() const { return minor_; }
+	unsigned int deviceMajor() const { return major_; }
+	unsigned int deviceMinor() const { return minor_; }
 
 	const std::vector<MediaPad *> &pads() const { return pads_; }