colo-compare: fix the dangerous assignment
PATCH 1/1 colo-compare: fix the dangerous assignment
--- net/colo-compare.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
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 ; }
Signature · 1 line
2.9.4
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 8ec14402029d783720f4312ed8a925548e1dad61Reported-by Peter Maydell <[email protected]>Reported-by Paolo Bonzini <[email protected]>Signed-off-by Mao Zhongyi <[email protected]>
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@@ -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
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 8ec14402029d783720f4312ed8a925548e1dad61Reported-by Peter Maydell <[email protected]>Reported-by Paolo Bonzini <[email protected]>Signed-off-by Mao Zhongyi <[email protected]>
Quoted 3 lines
Code-wise, this looks like a valid fix to the existing code.
Reviewed-by Darren Kenny <[email protected]>
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@@ -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
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 8ec14402029d783720f4312ed8a925548e1dad61Reported-by Peter Maydell <[email protected]>Reported-by Paolo Bonzini <[email protected]>Signed-off-by Mao Zhongyi <[email protected]>--- net/colo-compare.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/colo-compare.c +0
-0
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
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 8ec14402029d783720f4312ed8a925548e1dad61Reported-by Peter Maydell <[email protected]>Reported-by Paolo Bonzini <[email protected]>Signed-off-by Mao Zhongyi <[email protected]>--- net/colo-compare.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)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;
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
-0return 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
Jason Wang
AppliedQuoted 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 8ec14402029d783720f4312ed8a925548e1dad61Reported-by Peter Maydell <[email protected]>Reported-by Paolo Bonzini <[email protected]>Signed-off-by Mao Zhongyi <[email protected]>--- net/colo-compare.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/colo-compare.c +0
-0
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.