qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC 1/5] nbd: Correct name comparison for export_set_name(


From: Max Reitz
Subject: [Qemu-devel] [RFC 1/5] nbd: Correct name comparison for export_set_name()
Date: Sat, 31 May 2014 20:43:08 +0200

exp->name == name is certainly true if both strings are equal and will
work for both of them being NULL (which is important to check here);
however, the strings may also be equal without having the same address,
in which case there is no need to replace the export's name either.
Therefore, add a check for this case.

Signed-off-by: Max Reitz <address@hidden>
---
 nbd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/nbd.c b/nbd.c
index e5084b6..0787cba 100644
--- a/nbd.c
+++ b/nbd.c
@@ -832,7 +832,7 @@ NBDExport *nbd_export_find(const char *name)
 
 void nbd_export_set_name(NBDExport *exp, const char *name)
 {
-    if (exp->name == name) {
+    if (exp->name == name || (exp->name && name && !strcmp(exp->name, name))) {
         return;
     }
 
-- 
1.9.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]