[libcamera-devel] libcamera: raspberry: Align include guard

Message ID 20200526133105.3289924-1-niklas.soderlund@ragnatech.se
State Accepted
Commit c6e9c750f63bbfcd323287854513d967c57fe0b2
Headers show
Series
  • [libcamera-devel] libcamera: raspberry: Align include guard
Related show

Commit Message

Niklas Söderlund May 26, 2020, 1:31 p.m. UTC
The preprocessor directive '#pragma once' is non-standard, replace it
with the include guard used elsewhere in libcamera.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
---
 src/libcamera/pipeline/raspberrypi/staggered_ctrl.h | 5 ++++-
 src/libcamera/pipeline/raspberrypi/vcsm.h           | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

Comments

Laurent Pinchart June 4, 2020, 12:01 a.m. UTC | #1
Hi Niklas,

Thank you for the patch.

On Tue, May 26, 2020 at 03:31:05PM +0200, Niklas Söderlund wrote:
> The preprocessor directive '#pragma once' is non-standard, replace it
> with the include guard used elsewhere in libcamera.
> 
> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

It's not standard indeed, but supported by all the compilers we have to
care about. I value consistency though, so

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

but I wouldn't necessarily rule out switching to '#pragma once'
everywhere in the future if there were compeling arguments to do so.

> ---
>  src/libcamera/pipeline/raspberrypi/staggered_ctrl.h | 5 ++++-
>  src/libcamera/pipeline/raspberrypi/vcsm.h           | 5 ++++-
>  2 files changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/src/libcamera/pipeline/raspberrypi/staggered_ctrl.h b/src/libcamera/pipeline/raspberrypi/staggered_ctrl.h
> index eef16eaac235093c..1076fde3e9ee5d74 100644
> --- a/src/libcamera/pipeline/raspberrypi/staggered_ctrl.h
> +++ b/src/libcamera/pipeline/raspberrypi/staggered_ctrl.h
> @@ -4,7 +4,8 @@
>   *
>   * staggered_ctrl.h - Helper for writing staggered ctrls to a V4L2 device.
>   */
> -#pragma once
> +#ifndef __LIBCAMERA_PIPELINE_RASPBERRYPI_STAGGERED_CTRL_H__
> +#define __LIBCAMERA_PIPELINE_RASPBERRYPI_STAGGERED_CTRL_H__
>  
>  #include <array>
>  #include <initializer_list>
> @@ -91,3 +92,5 @@ private:
>  } /* namespace RPi */
>  
>  } /* namespace libcamera */
> +
> +#endif /* __LIBCAMERA_PIPELINE_RASPBERRYPI_STAGGERED_CTRL_H__ */
> diff --git a/src/libcamera/pipeline/raspberrypi/vcsm.h b/src/libcamera/pipeline/raspberrypi/vcsm.h
> index daa06961e0571e35..e32c258809b7100c 100644
> --- a/src/libcamera/pipeline/raspberrypi/vcsm.h
> +++ b/src/libcamera/pipeline/raspberrypi/vcsm.h
> @@ -4,7 +4,8 @@
>   *
>   * vcsm.h - Helper class for vcsm allocations.
>   */
> -#pragma once
> +#ifndef __LIBCAMERA_PIPELINE_RASPBERRYPI_VCSM_H__
> +#define __LIBCAMERA_PIPELINE_RASPBERRYPI_VCSM_H__
>  
>  #include <iostream>
>  #include <mutex>
> @@ -144,3 +145,5 @@ private:
>  };
>  
>  } /* namespace RPi */
> +
> +#endif /* __LIBCAMERA_PIPELINE_RASPBERRYPI_VCSM_H__ */
Kieran Bingham June 4, 2020, 10:32 a.m. UTC | #2
Hi Niklas,

s/raspberry/raspberrypi/ in $SUBJECT

On 04/06/2020 01:01, Laurent Pinchart wrote:
> Hi Niklas,
> 
> Thank you for the patch.
> 
> On Tue, May 26, 2020 at 03:31:05PM +0200, Niklas Söderlund wrote:
>> The preprocessor directive '#pragma once' is non-standard, replace it
>> with the include guard used elsewhere in libcamera.
>>
>> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
> 
> It's not standard indeed, but supported by all the compilers we have to
> care about. I value consistency though, so
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
> but I wouldn't necessarily rule out switching to '#pragma once'
> everywhere in the future if there were compeling arguments to do so.

I'd go for consistency currently, and as this is really just a stylistic
thing in that case (that all our targets support #pragma once), we
should have a rule added to checksytle if possible...

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>


> 
>> ---
>>  src/libcamera/pipeline/raspberrypi/staggered_ctrl.h | 5 ++++-
>>  src/libcamera/pipeline/raspberrypi/vcsm.h           | 5 ++++-
>>  2 files changed, 8 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/libcamera/pipeline/raspberrypi/staggered_ctrl.h b/src/libcamera/pipeline/raspberrypi/staggered_ctrl.h
>> index eef16eaac235093c..1076fde3e9ee5d74 100644
>> --- a/src/libcamera/pipeline/raspberrypi/staggered_ctrl.h
>> +++ b/src/libcamera/pipeline/raspberrypi/staggered_ctrl.h
>> @@ -4,7 +4,8 @@
>>   *
>>   * staggered_ctrl.h - Helper for writing staggered ctrls to a V4L2 device.
>>   */
>> -#pragma once
>> +#ifndef __LIBCAMERA_PIPELINE_RASPBERRYPI_STAGGERED_CTRL_H__
>> +#define __LIBCAMERA_PIPELINE_RASPBERRYPI_STAGGERED_CTRL_H__
>>  
>>  #include <array>
>>  #include <initializer_list>
>> @@ -91,3 +92,5 @@ private:
>>  } /* namespace RPi */
>>  
>>  } /* namespace libcamera */
>> +
>> +#endif /* __LIBCAMERA_PIPELINE_RASPBERRYPI_STAGGERED_CTRL_H__ */
>> diff --git a/src/libcamera/pipeline/raspberrypi/vcsm.h b/src/libcamera/pipeline/raspberrypi/vcsm.h
>> index daa06961e0571e35..e32c258809b7100c 100644
>> --- a/src/libcamera/pipeline/raspberrypi/vcsm.h
>> +++ b/src/libcamera/pipeline/raspberrypi/vcsm.h
>> @@ -4,7 +4,8 @@
>>   *
>>   * vcsm.h - Helper class for vcsm allocations.
>>   */
>> -#pragma once
>> +#ifndef __LIBCAMERA_PIPELINE_RASPBERRYPI_VCSM_H__
>> +#define __LIBCAMERA_PIPELINE_RASPBERRYPI_VCSM_H__
>>  
>>  #include <iostream>
>>  #include <mutex>
>> @@ -144,3 +145,5 @@ private:
>>  };
>>  
>>  } /* namespace RPi */
>> +
>> +#endif /* __LIBCAMERA_PIPELINE_RASPBERRYPI_VCSM_H__ */
>

Patch

diff --git a/src/libcamera/pipeline/raspberrypi/staggered_ctrl.h b/src/libcamera/pipeline/raspberrypi/staggered_ctrl.h
index eef16eaac235093c..1076fde3e9ee5d74 100644
--- a/src/libcamera/pipeline/raspberrypi/staggered_ctrl.h
+++ b/src/libcamera/pipeline/raspberrypi/staggered_ctrl.h
@@ -4,7 +4,8 @@ 
  *
  * staggered_ctrl.h - Helper for writing staggered ctrls to a V4L2 device.
  */
-#pragma once
+#ifndef __LIBCAMERA_PIPELINE_RASPBERRYPI_STAGGERED_CTRL_H__
+#define __LIBCAMERA_PIPELINE_RASPBERRYPI_STAGGERED_CTRL_H__
 
 #include <array>
 #include <initializer_list>
@@ -91,3 +92,5 @@  private:
 } /* namespace RPi */
 
 } /* namespace libcamera */
+
+#endif /* __LIBCAMERA_PIPELINE_RASPBERRYPI_STAGGERED_CTRL_H__ */
diff --git a/src/libcamera/pipeline/raspberrypi/vcsm.h b/src/libcamera/pipeline/raspberrypi/vcsm.h
index daa06961e0571e35..e32c258809b7100c 100644
--- a/src/libcamera/pipeline/raspberrypi/vcsm.h
+++ b/src/libcamera/pipeline/raspberrypi/vcsm.h
@@ -4,7 +4,8 @@ 
  *
  * vcsm.h - Helper class for vcsm allocations.
  */
-#pragma once
+#ifndef __LIBCAMERA_PIPELINE_RASPBERRYPI_VCSM_H__
+#define __LIBCAMERA_PIPELINE_RASPBERRYPI_VCSM_H__
 
 #include <iostream>
 #include <mutex>
@@ -144,3 +145,5 @@  private:
 };
 
 } /* namespace RPi */
+
+#endif /* __LIBCAMERA_PIPELINE_RASPBERRYPI_VCSM_H__ */