Skip to contentSkip to conversation

colo-compare: fix the dangerous assignment

PATCH Applied Mao Zhongyi 4 participants 6 messages Nov 16, 2017 – Nov 17, 2017 Networking

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 colo-compare: fix the dangerous assignment

Cc Peter Maydell <[email protected]>
Cc Jason Wang <[email protected]>
Cc Zhang Chen <[email protected]>
Cc Li Zhijian <[email protected]>
Cc Paolo Bonzini <[email protected]>
Fixes 8ec14402029d783720f4312ed8a925548e1dad61
---
 net/colo-compare.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/colo-compare.c +1 -1
index ccdcba2..1ce195f 100644
@@ -179,7 +179,7 @@ static int packet_enqueue(CompareState *s, int mode, Connection **con)
                          "drop packet");
         }
     }
-    con = &conn;
+    *con = conn;
 
     return 0;
 }
Signature · 1 line
2.9.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Mao Zhongyi
Cc Peter Maydell <[email protected]>
Cc Jason Wang <[email protected]>
Cc Zhang Chen <[email protected]>
Cc Li Zhijian <[email protected]>
Cc Paolo Bonzini <[email protected]>
Fixes 8ec14402029d783720f4312ed8a925548e1dad61

Code-wise, this looks like a valid fix to the existing code.

But testing wise, have you confirmed that things are behaving as you expected with the previous patch, since previously when calling colo_compare_connection(), the value of conn would have always been its initialized value of NULL.

Just want to be sure that fixing this doesn't end up breaking your expected behaviour given that all your testing before would have had a NULL value in conn.

Thanks,

Darren.

Quoted 23 lines

---
net/colo-compare.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
net/colo-compare.c +1 -1
index ccdcba2..1ce195f 100644
@@ -179,7 +179,7 @@ static int packet_enqueue(CompareState *s, int mode, Connection **con)
                         "drop packet");
        }
    }
-    con = &conn;
+    *con = conn;
 
    return 0;
 }
Signature · 1 line
2.9.4
#2 lore raw
Quoted 11 lines · Darren Kenny
Quoted 9 lines · Mao Zhongyi
Cc Peter Maydell <[email protected]>
Cc Jason Wang <[email protected]>
Cc Zhang Chen <[email protected]>
Cc Li Zhijian <[email protected]>
Cc Paolo Bonzini <[email protected]>
Fixes 8ec14402029d783720f4312ed8a925548e1dad61
Quoted 3 lines

Code-wise, this looks like a valid fix to the existing code.

Hi, Darren

Quoted 4 lines

But testing wise, have you confirmed that things are behaving as you expected with the previous patch, since previously when calling colo_compare_connection(), the value of conn would have always been its initialized value of NULL.

Well, in my test machine the code like *con = conn, but when I made the patch on another machine I wrote the code con = &conn carelessly.

Quoted 3 lines

Just want to be sure that fixing this doesn't end up breaking your expected behaviour given that all your testing before would have had a NULL value in conn.

Thanks for the kind reminder.

Thanks,
Mao

Quoted 30 lines

Thanks,

Darren.

Quoted 23 lines

---
net/colo-compare.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
net/colo-compare.c +1 -2
index ccdcba2..1ce195f 100644
@@ -179,7 +179,7 @@ static int packet_enqueue(CompareState *s, int mode, Connection **con)
                         "drop packet");
        }
    }
-    con = &conn;
+    *con = conn;
 
    return 0;
 }
--

2.9.4

#3 lore raw
In reply to Mao Zhongyi

Am 16.11.2017 um 03:28 schrieb Mao Zhongyi:

Quoted 18 lines
Cc Peter Maydell <[email protected]>
Cc Jason Wang <[email protected]>
Cc Zhang Chen <[email protected]>
Cc Li Zhijian <[email protected]>
Cc Paolo Bonzini <[email protected]>
Fixes 8ec14402029d783720f4312ed8a925548e1dad61
---
 net/colo-compare.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/colo-compare.c +0 -0
index ccdcba2..1ce195f 100644

net/colo-compare.c static int packet_enqueue(CompareState *s, int mode, Connection **con) · line 185

Quoted 8 lines
net/colo-compare.c +1 -1
@@ -179,7 +179,7 @@ static int packet_enqueue(CompareState *s, int mode, Connection **con)
                          "drop packet");
         }
     }
-    con = &conn;
+    *con = conn;
 
     return 0;
 }

The patch is definitely needed if the new function parameter con should work.

It also fixes a gcc compiler warning:
net/colo-compare.c:139:67: warning: parameter ‘con’ set but not used [-Wunused-but-set-parameter]

I‌ think using -Wextra would be really good to catch such bugs earlier.

Regards,
Stefan

#4 lore raw
Quoted 25 lines · Stefan Weil

Am 16.11.2017 um 03:28 schrieb Mao Zhongyi:

Quoted 24 lines
Cc Peter Maydell <[email protected]>
Cc Jason Wang <[email protected]>
Cc Zhang Chen <[email protected]>
Cc Li Zhijian <[email protected]>
Cc Paolo Bonzini <[email protected]>
Fixes 8ec14402029d783720f4312ed8a925548e1dad61
---
 net/colo-compare.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/colo-compare.c +1 -1
index ccdcba2..1ce195f 100644
@@ -179,7 +179,7 @@ static int packet_enqueue(CompareState *s, int mode, Connection **con)
                          "drop packet");
         }
     }
-    con = &conn;
+    *con = conn;
 
Quoted 2 lines

net/colo-compare.c static int packet_enqueue(CompareState *s, int mode, Connection **con) · line 185

Quoted 2 lines
net/colo-compare.c +0 -0
     return 0;
 }

Hi, Stefan

Quoted 8 lines

The patch is definitely needed if the new function parameter con should work.

It also fixes a gcc compiler warning:
net/colo-compare.c:139:67: warning: parameter ‘con’ set but not used [-Wunused-but-set-parameter]

I‌ think using -Wextra would be really good to catch such bugs earlier.

Thanks a bunch. I got it. :)

Mao

Applied
#5 lore raw
In reply to Mao Zhongyi
Quoted 18 lines · Mao Zhongyi
Cc Peter Maydell <[email protected]>
Cc Jason Wang <[email protected]>
Cc Zhang Chen <[email protected]>
Cc Li Zhijian <[email protected]>
Cc Paolo Bonzini <[email protected]>
Fixes 8ec14402029d783720f4312ed8a925548e1dad61
---
  net/colo-compare.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
net/colo-compare.c +0 -0
index ccdcba2..1ce195f 100644

net/colo-compare.c static int packet_enqueue(CompareState *s, int mode, Connection **con) · line 185

Quoted 8 lines
net/colo-compare.c +1 -1
@@ -179,7 +179,7 @@ static int packet_enqueue(CompareState *s, int mode, Connection **con)
                           "drop packet");
          }
      }
-    con = &conn;
+    *con = conn;
 
      return 0;
  }

Applied, thanks.