[PATCH 2/2] fixed warning: comparison of unsigned expression >= 0 is always true [-Werror=type-limits]

Andreas Heinig andreas.heinig at cs.tu-dortmund.de
Thu May 2 11:15:20 UTC 2013


On Thursday 02 May 2013 12:54:03 you wrote:
> ---
>  c/src/lib/libbsp/shared/include/irq-generic.h |    4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/c/src/lib/libbsp/shared/include/irq-generic.h
> b/c/src/lib/libbsp/shared/include/irq-generic.h index 47fc3e2..395f615
> 100644
> --- a/c/src/lib/libbsp/shared/include/irq-generic.h
> +++ b/c/src/lib/libbsp/shared/include/irq-generic.h
> @@ -144,8 +144,12 @@ static inline rtems_vector_number
> bsp_interrupt_handler_index( */
>    static inline bool bsp_interrupt_is_valid_vector(rtems_vector_number
> vector) {
> +#if BSP_INTERRUPT_VECTOR_MIN > 0
>      return BSP_INTERRUPT_VECTOR_MIN <= (rtems_vector_number) vector
>        && vector <= (rtems_vector_number) BSP_INTERRUPT_VECTOR_MAX;
> +#else
> +    return vector <= (rtems_vector_number) BSP_INTERRUPT_VECTOR_MAX;
> +#endif
>    }
>  #endif

Sorry for the inconvenience, but I misinterpreted the compiler warning. My 
first patch is nonsense. The second patch, however, will fix the initial 
compiler warning already.

Here is the new version of patch 2:

diff --git a/c/src/lib/libbsp/shared/include/irq-generic.h 
b/c/src/lib/libbsp/shared/include/irq-generic.h
index d365c0c..386032b 100644
--- a/c/src/lib/libbsp/shared/include/irq-generic.h
+++ b/c/src/lib/libbsp/shared/include/irq-generic.h
@@ -144,8 +144,12 @@ static inline rtems_vector_number 
bsp_interrupt_handler_index(
    */
   static inline bool bsp_interrupt_is_valid_vector(rtems_vector_number 
vector)
   {
+#if BSP_INTERRUPT_VECTOR_MIN > 0
     return (rtems_vector_number) BSP_INTERRUPT_VECTOR_MIN <= vector
       && vector <= (rtems_vector_number) BSP_INTERRUPT_VECTOR_MAX;
+#else
+    return vector <= (rtems_vector_number) BSP_INTERRUPT_VECTOR_MAX;
+#endif
   }
 #endif
 
-- 
1.7.10.4



More information about the devel mailing list