diff mbox

[2/2] qemu-io: Fix if scoping bug

Message ID 004f3f00feb28f2d8f9f7c837e06a8fd414dfd73.1310361865.git.devin122@gmail.com
State New
Headers show

Commit Message

Devin Nakamura July 11, 2011, 5:25 a.m. UTC
Fix a bug caused by lack of braces in if statement

Lack of braces means that if(count & 0x1ff) is never reached

Conflicts:

	qemu-io.c

Signed-off-by: Devin Nakamura <devin122@gmail.com>
---
 qemu-io.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Comments

Stefan Hajnoczi July 11, 2011, 9:47 a.m. UTC | #1
On Mon, Jul 11, 2011 at 6:25 AM, Devin Nakamura <devin122@gmail.com> wrote:
> diff --git a/qemu-io.c b/qemu-io.c
> index e484f40..85cfe27 100644
> --- a/qemu-io.c
> +++ b/qemu-io.c
> @@ -449,7 +449,7 @@ static int read_f(int argc, char **argv)
>         return 0;
>     }
>
> -    if (!pflag)
> +    if (!pflag) {
>         if (offset & 0x1ff) {
>             printf("offset %" PRId64 " is not sector aligned\n",
>                    offset);

Wait, this is not enough.  The indentation and curlies are so broken
here :).  The if (offset & 0x1ff) statement needs a closing curly.

The code should be:
if (!pflag) {
    if (offset & 0x1ff) {
                    printf("offset %" PRId64 " is not sector aligned\n",
                           offset);
        return 0;
    }

    if (count & 0x1ff) {
        printf("count %d is not sector aligned\n",
            count);
        return 0;
    }
}

Stefan
Kevin Wolf July 11, 2011, 1:18 p.m. UTC | #2
Am 11.07.2011 11:47, schrieb Stefan Hajnoczi:
> On Mon, Jul 11, 2011 at 6:25 AM, Devin Nakamura <devin122@gmail.com> wrote:
>> diff --git a/qemu-io.c b/qemu-io.c
>> index e484f40..85cfe27 100644
>> --- a/qemu-io.c
>> +++ b/qemu-io.c
>> @@ -449,7 +449,7 @@ static int read_f(int argc, char **argv)
>>         return 0;
>>     }
>>
>> -    if (!pflag)
>> +    if (!pflag) {
>>         if (offset & 0x1ff) {
>>             printf("offset %" PRId64 " is not sector aligned\n",
>>                    offset);
> 
> Wait, this is not enough.  The indentation and curlies are so broken
> here :).  The if (offset & 0x1ff) statement needs a closing curly.

It's actually there, patch 1 already contains it. Breaks bisectability,
of course.

Kevin
Stefan Hajnoczi July 11, 2011, 1:18 p.m. UTC | #3
On Mon, Jul 11, 2011 at 2:18 PM, Kevin Wolf <kwolf@redhat.com> wrote:
> Am 11.07.2011 11:47, schrieb Stefan Hajnoczi:
>> On Mon, Jul 11, 2011 at 6:25 AM, Devin Nakamura <devin122@gmail.com> wrote:
>>> diff --git a/qemu-io.c b/qemu-io.c
>>> index e484f40..85cfe27 100644
>>> --- a/qemu-io.c
>>> +++ b/qemu-io.c
>>> @@ -449,7 +449,7 @@ static int read_f(int argc, char **argv)
>>>         return 0;
>>>     }
>>>
>>> -    if (!pflag)
>>> +    if (!pflag) {
>>>         if (offset & 0x1ff) {
>>>             printf("offset %" PRId64 " is not sector aligned\n",
>>>                    offset);
>>
>> Wait, this is not enough.  The indentation and curlies are so broken
>> here :).  The if (offset & 0x1ff) statement needs a closing curly.
>
> It's actually there, patch 1 already contains it. Breaks bisectability,
> of course.

Devin,
Please make patch 1 only fix formatting and move any other changes
into later patches.

Stefan
diff mbox

Patch

diff --git a/qemu-io.c b/qemu-io.c
index e484f40..85cfe27 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -449,7 +449,7 @@  static int read_f(int argc, char **argv)
         return 0;
     }
 
-    if (!pflag)
+    if (!pflag) {
         if (offset & 0x1ff) {
             printf("offset %" PRId64 " is not sector aligned\n",
                    offset);