[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bulk] grub2: commands/cmp.c: grub_cmd_cmp()
From: |
Vincent Pelletier |
Subject: |
Re: [Bulk] grub2: commands/cmp.c: grub_cmd_cmp() |
Date: |
Wed, 29 Jun 2005 17:21:13 +0200 |
User-agent: |
Debian Thunderbird 1.0.2 (X11/20050602) |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Rodrigo Steinmüller Wanderley wrote:
> When reading the cmp commands I found some points I
> couldn't understand, think they are bugs, but maybe some of you guys can
> prove me wrong...
You are right :). Thanks for your bug report. Please tell me if this
patch is ok for you.
nb: I haven't tested these changes beyond "make", but I think they are
trivial enough to be trusted...
2005-06-29 Vincent Pelletier <address@hidden>
* commands/cmp.c
(grub_cmd_cmp): Close the right file at the right time.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQFCwrxoFEQoKRQyjtURAkebAJ0d0+or1iWfjjGvDJUWeQTzPXm8JQCgmvum
QFQJwUA+/ff5iNdG1DaKZ+w=
=4HC3
-----END PGP SIGNATURE-----
Index: cmp.c
===================================================================
RCS file: /cvsroot/grub/grub2/commands/cmp.c,v
retrieving revision 1.2
diff -u -p -r1.2 cmp.c
--- cmp.c 4 Apr 2004 13:46:00 -0000 1.2
+++ cmp.c 29 Jun 2005 15:14:59 -0000
@@ -44,7 +44,7 @@ grub_cmd_cmp (struct grub_arg_list *stat
file2 = grub_file_open (args[1]);
if (! file2)
{
- grub_file_close (file2);
+ grub_file_close (file1);
return grub_errno;
}
@@ -67,7 +67,7 @@ grub_cmd_cmp (struct grub_arg_list *stat
rd2 = grub_file_read (file2, buf2, 512);
if (rd1 != rd2)
- return 0;
+ goto cleanup;
for (i = 0; i < 512; i++)
{
@@ -76,10 +76,7 @@ grub_cmd_cmp (struct grub_arg_list *stat
grub_printf ("Differ at the offset %d: 0x%x [%s], 0x%x
[%s]\n",
i + pos, buf1[i], args[0],
buf2[i], args[1]);
-
- grub_file_close (file1);
- grub_file_close (file2);
- return 0;
+ goto cleanup;
}
}
pos += 512;
@@ -87,11 +84,12 @@ grub_cmd_cmp (struct grub_arg_list *stat
} while (rd2);
}
+ grub_printf ("The files are identical.\n");
+
+cleanup:
grub_file_close (file1);
grub_file_close (file2);
- grub_printf ("The files are identical.\n");
-
return 0;
}