Patchwork [24/26] uefi: uefidump: cast to ptrdiff_t to remove mixed signed/unsigned comparison

login
register
mail settings
Submitter Colin King
Date Oct. 14, 2012, 8:32 p.m.
Message ID <1350246738-31699-25-git-send-email-colin.king@canonical.com>
Download mbox | patch
Permalink /patch/191412/
State Accepted
Headers show

Comments

Colin King - Oct. 14, 2012, 8:32 p.m.
From: Colin Ian King <colin.king@canonical.com>

We shouldn't be comparing a ptrdiff_t to a size_t, so cast to avoid
a signed/unsigned comparison.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/uefi/uefidump/uefidump.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Alex Hung - Oct. 15, 2012, 7:08 a.m.
On 10/15/2012 04:32 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> We shouldn't be comparing a ptrdiff_t to a size_t, so cast to avoid
> a signed/unsigned comparison.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/uefi/uefidump/uefidump.c |    3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/src/uefi/uefidump/uefidump.c b/src/uefi/uefidump/uefidump.c
> index 11c40e9..d09db0b 100644
> --- a/src/uefi/uefidump/uefidump.c
> +++ b/src/uefi/uefidump/uefidump.c
> @@ -16,6 +16,7 @@
>    * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
>    *
>    */
> +#include <stddef.h>
>   #include <inttypes.h>
>
>   #include "fwts.h"
> @@ -645,7 +646,7 @@ static void uefidump_info_signature_support(fwts_framework *fw, fwts_uefi_var *v
>   		if (var->datalen)
>   			fwts_log_info_verbatum(fw, "  Signature GUIDs:");
>
> -		while (data - var->data < var->datalen) {
> +		while (data - var->data < (ptrdiff_t)var->datalen) {
>   			fwts_guid_buf_to_str(data, guid_str, sizeof(guid_str));
>   			fwts_log_info_verbatum(fw, "    %s", guid_str);
>   			data += 16;
>

Acked-by: Alex Hung <alex.hung@canonical.com>
Keng-Yu Lin - Oct. 17, 2012, 7:57 a.m.
On Mon, Oct 15, 2012 at 4:32 AM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> We shouldn't be comparing a ptrdiff_t to a size_t, so cast to avoid
> a signed/unsigned comparison.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/uefi/uefidump/uefidump.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/src/uefi/uefidump/uefidump.c b/src/uefi/uefidump/uefidump.c
> index 11c40e9..d09db0b 100644
> --- a/src/uefi/uefidump/uefidump.c
> +++ b/src/uefi/uefidump/uefidump.c
> @@ -16,6 +16,7 @@
>   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
>   *
>   */
> +#include <stddef.h>
>  #include <inttypes.h>
>
>  #include "fwts.h"
> @@ -645,7 +646,7 @@ static void uefidump_info_signature_support(fwts_framework *fw, fwts_uefi_var *v
>                 if (var->datalen)
>                         fwts_log_info_verbatum(fw, "  Signature GUIDs:");
>
> -               while (data - var->data < var->datalen) {
> +               while (data - var->data < (ptrdiff_t)var->datalen) {
>                         fwts_guid_buf_to_str(data, guid_str, sizeof(guid_str));
>                         fwts_log_info_verbatum(fw, "    %s", guid_str);
>                         data += 16;
> --
> 1.7.10.4
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>

Patch

diff --git a/src/uefi/uefidump/uefidump.c b/src/uefi/uefidump/uefidump.c
index 11c40e9..d09db0b 100644
--- a/src/uefi/uefidump/uefidump.c
+++ b/src/uefi/uefidump/uefidump.c
@@ -16,6 +16,7 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
  */
+#include <stddef.h>
 #include <inttypes.h>
 
 #include "fwts.h"
@@ -645,7 +646,7 @@  static void uefidump_info_signature_support(fwts_framework *fw, fwts_uefi_var *v
 		if (var->datalen)
 			fwts_log_info_verbatum(fw, "  Signature GUIDs:");
 
-		while (data - var->data < var->datalen) {
+		while (data - var->data < (ptrdiff_t)var->datalen) {
 			fwts_guid_buf_to_str(data, guid_str, sizeof(guid_str));
 			fwts_log_info_verbatum(fw, "    %s", guid_str);
 			data += 16;