Skip to contentSkip to conversation

Remove local ram_size that hides global one

PATCH In review Christian Borntraeger 4 participants 7 messages Nov 13, 2012 – Nov 20, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 6/24 Remove local ram_size that hides global one

From: Heinz Graalfs <[email protected]>

The global variable 'ram_size' is hidden by the local variable declaration in s390_init()

---
 hw/s390-virtio.c |    1 -
 1 file changed, 1 deletion(-)
hw/s390-virtio.c +0 -1
index ebec844..78477af 100644
@@ -155,7 +155,6 @@ unsigned s390_del_running_cpu(CPUS390XState *env)
 static void s390_init(QEMUMachineInitArgs *args)
 {
     ram_addr_t my_ram_size = args->ram_size;
-    ram_addr_t ram_size = args->ram_size;
     const char *cpu_model = args->cpu_model;
     const char *kernel_filename = args->kernel_filename;
     const char *kernel_cmdline = args->kernel_cmdline;
Signature · 1 line
1.7.10.1
#1 lore raw
Quoted 4 lines · Christian Borntraeger

From: Heinz Graalfs <[email protected]>

The global variable 'ram_size' is hidden by the local variable declaration in s390_init()

That's the point of Eduardo's patch, no? Or do we need access to the global to change its value afterwards? If so, please write a reasonable patch description that actually explains the problem.

Alex

Quoted 22 lines

---
hw/s390-virtio.c | 1 -

1 file changed, 1 deletion(-)
hw/s390-virtio.c +0 -1
index ebec844..78477af 100644
@@ -155,7 +155,6 @@ unsigned s390_del_running_cpu(CPUS390XState *env)
 static void s390_init(QEMUMachineInitArgs *args)
 {
    ram_addr_t my_ram_size = args->ram_size;
-    ram_addr_t ram_size = args->ram_size;
    const char *cpu_model = args->cpu_model;
    const char *kernel_filename = args->kernel_filename;
    const char *kernel_cmdline = args->kernel_cmdline;
Signature · 1 line
1.7.10.1
#2 lore raw
Quoted 10 lines · Alexander Graf
Quoted 4 lines · Christian Borntraeger

From: Heinz Graalfs <[email protected]>

The global variable 'ram_size' is hidden by the local variable declaration in s390_init()

That's the point of Eduardo's patch, no? Or do we need access to the global to change its value afterwards?

The function later does:

    /* lets propagate the changed ram size into the global variable. */
    ram_size = my_ram_size;

which frankly I think is pretty nasty but then we've never had a very good mechanism for specifying board-specific restrictions around the memory size.

-- PMM

Reviewed-by
#3 lore raw
In reply to Alexander Graf
Quoted 10 lines · Alexander Graf
Quoted 4 lines · Christian Borntraeger

From: Heinz Graalfs <[email protected]>

The global variable 'ram_size' is hidden by the local variable declaration in s390_init()

That's the point of Eduardo's patch, no? Or do we need access to the global to change its value afterwards? If so, please write a reasonable patch description that actually explains the problem.

Actually, I wanted to keep the existing behavior (whatever it was), and use local variables to replace the old function parameters, and change nothing else. Most machines used a local variable named 'ram_size', but the parameter to s390_init() was named 'my_ram_size'.

So, considering that this at least restores the previous behavior:

Quoted 26 lines

Alex

Quoted 22 lines

---
hw/s390-virtio.c | 1 -

1 file changed, 1 deletion(-)
hw/s390-virtio.c +0 -1
index ebec844..78477af 100644
@@ -155,7 +155,6 @@ unsigned s390_del_running_cpu(CPUS390XState *env)
 static void s390_init(QEMUMachineInitArgs *args)
 {
    ram_addr_t my_ram_size = args->ram_size;
-    ram_addr_t ram_size = args->ram_size;
    const char *cpu_model = args->cpu_model;
    const char *kernel_filename = args->kernel_filename;
    const char *kernel_cmdline = args->kernel_cmdline;
Signature · 1 line
1.7.10.1
Signature · 1 line
Eduardo
#4 lore raw
Quoted 12 lines · Eduardo Habkost
Quoted 10 lines · Alexander Graf
Quoted 4 lines · Christian Borntraeger

From: Heinz Graalfs <[email protected]>

The global variable 'ram_size' is hidden by the local variable declaration in s390_init()

That's the point of Eduardo's patch, no? Or do we need access to the global to change its value afterwards? If so, please write a reasonable patch description that actually explains the problem.

Quoted 8 lines

Actually, I wanted to keep the existing behavior (whatever it was), and use local variables to replace the old function parameters, and change nothing else. Most machines used a local variable named 'ram_size', but the parameter to s390_init() was named 'my_ram_size'.

So, considering that this at least restores the previous behavior:

Yup, Heinz, please resend with a patch description that actually tells us what the problem is.

Alex

#5 lore raw

PATCH 1/1 s390: Fix ram_size updating in machine init

From: Heinz Graalfs <[email protected]>

The global variable 'ram_size' is hidden by the local variable declaration in s390_init(). Since we want to update the global ram size in certain cases we must not use a local ram_size variable.
- This fixes booting with unusual ram sizes like -m 67001
- This changes behaviour back to the situation before commit 5f072e1f3075bd869e0ace9f2545a85992ac0084
(create struct for machine initialization arguments)

---
 hw/s390-virtio.c |    1 -
 1 file changed, 1 deletion(-)
hw/s390-virtio.c +0 -1
index ebec844..78477af 100644
@@ -155,7 +155,6 @@ unsigned s390_del_running_cpu(CPUS390XState *env)
 static void s390_init(QEMUMachineInitArgs *args)
 {
     ram_addr_t my_ram_size = args->ram_size;
-    ram_addr_t ram_size = args->ram_size;
     const char *cpu_model = args->cpu_model;
     const char *kernel_filename = args->kernel_filename;
     const char *kernel_cmdline = args->kernel_cmdline;
Signature · 1 line
1.7.10.1
#6 lore raw

Re: [Qemu-devel] [PATCH 1/1] s390: Fix ram_size updating in machine init

Quoted 11 lines · Christian Borntraeger

From: Heinz Graalfs <[email protected]>

The global variable 'ram_size' is hidden by the local variable declaration in s390_init(). Since we want to update the global ram size in certain cases we must not use a local ram_size variable.
- This fixes booting with unusual ram sizes like -m 67001
- This changes behaviour back to the situation before commit 5f072e1f3075bd869e0ace9f2545a85992ac0084
(create struct for machine initialization arguments)

Quoted 3 lines

Thanks, applied to s390-next.

Alex

Quoted 19 lines

---
hw/s390-virtio.c | 1 -

1 file changed, 1 deletion(-)
hw/s390-virtio.c +0 -1
index ebec844..78477af 100644
@@ -155,7 +155,6 @@ unsigned s390_del_running_cpu(CPUS390XState *env)
 static void s390_init(QEMUMachineInitArgs *args)
 {
    ram_addr_t my_ram_size = args->ram_size;
-    ram_addr_t ram_size = args->ram_size;
    const char *cpu_model = args->cpu_model;
    const char *kernel_filename = args->kernel_filename;
    const char *kernel_cmdline = args->kernel_cmdline;
Signature · 1 line
1.7.10.1