diff mbox

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

Message ID 1350246738-31699-25-git-send-email-colin.king@canonical.com
State Accepted
Headers show

Commit Message

Colin Ian King Oct. 14, 2012, 8:32 p.m. UTC
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(-)

Comments

Alex Hung Oct. 15, 2012, 7:08 a.m. UTC | #1
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. UTC | #2
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>
diff mbox

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;