Skip to contentSkip to conversation

sparc-dis: Remove redundant NULL check

PATCH Applied Stefan Weil 3 participants 9 messages Sep 3, 2012 – Sep 21, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sparc-dis: Remove redundant NULL check

Report from smatch:
sparc-dis.c:2664 build_hash_table(14) info:
redundant null check on hash_buf calling free()

---

Coding style was not fixed.

- sw

 sparc-dis.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
sparc-dis.c +1 -2
index cdd337a..ef28835 100644
@@ -2660,8 +2660,7 @@ build_hash_table (const sparc_opcode **opcode_table,
 
   memset (hash_table, 0, HASH_SIZE * sizeof (hash_table[0]));
   memset (hash_count, 0, HASH_SIZE * sizeof (hash_count[0]));
-  if (hash_buf != NULL)
-    free (hash_buf);
+  free (hash_buf);
   hash_buf = malloc (sizeof (* hash_buf) * num_opcodes);
   for (i = num_opcodes - 1; i >= 0; --i)
     {
Signature · 1 line
1.7.10
#2 lore raw
In reply to Stefan Weil

Am 03.09.2012 22:23, schrieb Stefan Weil:

Quoted 19 lines

Report from smatch:
sparc-dis.c:2664 build_hash_table(14) info:
redundant null check on hash_buf calling free()

---

Coding style was not fixed.

- sw

 sparc-dis.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
sparc-dis.c +0 -0
index cdd337a..ef28835 100644

sparc-dis.c build_hash_table (const sparc_opcode **opcode_table, · line 2666

Quoted 9 lines
sparc-dis.c +1 -2
@@ -2660,8 +2660,7 @@ build_hash_table (const sparc_opcode **opcode_table,
 
   memset (hash_table, 0, HASH_SIZE * sizeof (hash_table[0]));
   memset (hash_count, 0, HASH_SIZE * sizeof (hash_count[0]));
-  if (hash_buf != NULL)
-    free (hash_buf);
+  free (hash_buf);
   hash_buf = malloc (sizeof (* hash_buf) * num_opcodes);
   for (i = num_opcodes - 1; i >= 0; --i)
     {

*-dis sounds like binutils - did upstream drop the if, too? If not, then diverging for a non-issue does not seem necessary.

Having said that, it's amazing what fixes you come up with. Did you describe the use of that tool in some posting or in the Wiki?

Regards,
Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#3 lore raw
Quoted 21 lines · Andreas Färber

Am 03.09.2012 22:23, schrieb Stefan Weil:

Quoted 20 lines

Report from smatch:
sparc-dis.c:2664 build_hash_table(14) info:
redundant null check on hash_buf calling free()

---

Coding style was not fixed.

- sw

 sparc-dis.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
sparc-dis.c +0 -0
index cdd337a..ef28835 100644
@@ -2660,8 +2660,7 @@ build_hash_table (const sparc_opcode **opcode_table,
 
Quoted 11 lines

sparc-dis.c build_hash_table (const sparc_opcode **opcode_table, · line 2666

Quoted 8 lines
sparc-dis.c +1 -2
   memset (hash_table, 0, HASH_SIZE * sizeof (hash_table[0]));
   memset (hash_count, 0, HASH_SIZE * sizeof (hash_count[0]));
-  if (hash_buf != NULL)
-    free (hash_buf);
+  free (hash_buf);
   hash_buf = malloc (sizeof (* hash_buf) * num_opcodes);
   for (i = num_opcodes - 1; i >= 0; --i)
     {

*-dis sounds like binutils - did upstream drop the if, too? If not, then diverging for a non-issue does not seem necessary.

Ah, good point. I don't think we should apply this patch :P.

Dropping the patch from qemu-trivial until this discussion finishes.

Stefan

#4 lore raw

Am 05.09.2012 18:55, schrieb Stefan Hajnoczi:

Quoted 34 lines · Andreas Färber
Quoted 21 lines

Am 03.09.2012 22:23, schrieb Stefan Weil:

Quoted 20 lines

Report from smatch:
sparc-dis.c:2664 build_hash_table(14) info:
redundant null check on hash_buf calling free()

---

Coding style was not fixed.

- sw

  sparc-dis.c |    3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
sparc-dis.c +0 -0
index cdd337a..ef28835 100644
@@ -2660,8 +2660,7 @@ build_hash_table (const sparc_opcode **opcode_table,
 
Quoted 11 lines

sparc-dis.c build_hash_table (const sparc_opcode **opcode_table, · line 2666

Quoted 8 lines
sparc-dis.c +1 -2
    memset (hash_table, 0, HASH_SIZE * sizeof (hash_table[0]));
    memset (hash_count, 0, HASH_SIZE * sizeof (hash_count[0]));
-  if (hash_buf != NULL)
-    free (hash_buf);
+  free (hash_buf);
    hash_buf = malloc (sizeof (* hash_buf) * num_opcodes);
    for (i = num_opcodes - 1; i>= 0; --i)
      {

*-dis sounds like binutils - did upstream drop the if, too? If not, then diverging for a non-issue does not seem necessary.

Quoted 5 lines

Ah, good point. I don't think we should apply this patch :P.

Dropping the patch from qemu-trivial until this discussion finishes.

Stefan

AFAIK, binutils moved to GPL 3. Therefore I don't expect that QEMU will update to upstream in the next years.

We'll have to maintain the code which we have.

Try "git log *-dis.c" or "gitk *-dis.c": there are already lots of more trivial changes which got applied to the disassembler files.

=> The patch should be applied.

Regards,
Stefan

#5 lore raw

Am 05.09.2012 19:15, schrieb Stefan Weil:

Quoted 6 lines

AFAIK, binutils moved to GPL 3. Therefore I don't expect that QEMU will update to upstream in the next years.

We'll have to maintain the code which we have.

Quoted 7 lines

Try "git log *-dis.c" or "gitk *-dis.c": there are already lots of more trivial changes which got applied to the disassembler files.

=> The patch should be applied.

Regards,
Stefan

Here is some additional information:

binutils switched from GPL 2 to GPL 3 with version 2.18:

Changes in 2.18:

* The binutils sources are now released under version 3 of the GNU General Public License.

sparc-dis.c is already based on 2.17, so we won't get anything newer. Even the latest version still uses the redundant NULL check, so I can send my patch to the binutils maintainers, too.

Regards,
Stefan

#6 lore raw

Am 05.09.2012 19:45, schrieb Stefan Weil:

Quoted 25 lines

Am 05.09.2012 19:15, schrieb Stefan Weil:

Quoted 6 lines

AFAIK, binutils moved to GPL 3. Therefore I don't expect that QEMU will update to upstream in the next years.

We'll have to maintain the code which we have.

Quoted 7 lines

Try "git log *-dis.c" or "gitk *-dis.c": there are already lots of more trivial changes which got applied to the disassembler files.

=> The patch should be applied.

Regards,
Stefan

Here is some additional information:

binutils switched from GPL 2 to GPL 3 with version 2.18:

Changes in 2.18:

* The binutils sources are now released under version 3 of the GNU General Public License.

Quoted 7 lines

sparc-dis.c is already based on 2.17, so we won't get anything newer. Even the latest version still uses the redundant NULL check, so I can send my patch to the binutils maintainers, too.

Regards,
Stefan

Ping? If nobody objects, I suggest to apply the patch via qemu-trivial.

Regards

Stefan W.

#7 lore raw

Am 20.09.2012 19:03, schrieb Stefan Weil:

Quoted 30 lines

Am 05.09.2012 19:45, schrieb Stefan Weil:

Quoted 29 lines

Am 05.09.2012 19:15, schrieb Stefan Weil:

Quoted 6 lines

AFAIK, binutils moved to GPL 3. Therefore I don't expect that QEMU will update to upstream in the next years.

We'll have to maintain the code which we have.

Quoted 7 lines

Try "git log *-dis.c" or "gitk *-dis.c": there are already lots of more trivial changes which got applied to the disassembler files.

=> The patch should be applied.

Regards,
Stefan

Here is some additional information:

binutils switched from GPL 2 to GPL 3 with version 2.18:

Changes in 2.18:

* The binutils sources are now released under version 3 of the GNU General
Public License.

sparc-dis.c is already based on 2.17, so we won't get anything newer. Even the latest version still uses the redundant NULL check, so I can send my patch to the binutils maintainers, too.

So did you? And did they accept it?

Regards,
Andreas

Quoted 5 lines

Ping? If nobody objects, I suggest to apply the patch via qemu-trivial.

Regards

Stefan W.

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#8 lore raw
In reply to Andreas Färber

Am 05.09.2012 17:51, schrieb Andreas Färber:

Quoted 34 lines

Am 03.09.2012 22:23, schrieb Stefan Weil:

Quoted 20 lines

Report from smatch:
sparc-dis.c:2664 build_hash_table(14) info:
redundant null check on hash_buf calling free()

---

Coding style was not fixed.

- sw

  sparc-dis.c |    3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
sparc-dis.c +0 -0
index cdd337a..ef28835 100644

sparc-dis.c build_hash_table (const sparc_opcode **opcode_table, · line 2666

Quoted 9 lines
sparc-dis.c +1 -2
@@ -2660,8 +2660,7 @@ build_hash_table (const sparc_opcode **opcode_table,
 
    memset (hash_table, 0, HASH_SIZE * sizeof (hash_table[0]));
    memset (hash_count, 0, HASH_SIZE * sizeof (hash_count[0]));
-  if (hash_buf != NULL)
-    free (hash_buf);
+  free (hash_buf);
    hash_buf = malloc (sizeof (* hash_buf) * num_opcodes);
    for (i = num_opcodes - 1; i>= 0; --i)
      {

*-dis sounds like binutils - did upstream drop the if, too? If not, then diverging for a non-issue does not seem necessary.

Quoted 3 lines

Having said that, it's amazing what fixes you come up with. Did you describe the use of that tool in some posting or in the Wiki?

I just added some initial text to http://wiki.qemu.org/Testing.

Quoted 4 lines

Regards,
Andreas