Message ID | 1453883380-10532-3-git-send-email-zhang.zhanghailiang@huawei.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 01/27/2016 04:29 PM, zhanghailiang wrote: > Make the helper object_create() public and fix its first > parameter to accept NULL value. Looks not very nice. Maybe pass a new predicate func for sanity check it better. > > Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com> > Cc: Paolo Bonzini <pbonzini@redhat.com> > --- > v2: > - New patch > --- > include/qemu-common.h | 2 ++ > vl.c | 4 ++-- > 2 files changed, 4 insertions(+), 2 deletions(-) > > diff --git a/include/qemu-common.h b/include/qemu-common.h > index 22b010c..52cf4fd 100644 > --- a/include/qemu-common.h > +++ b/include/qemu-common.h > @@ -500,4 +500,6 @@ int parse_debug_env(const char *name, int max, int initial); > const char *qemu_ether_ntoa(const MACAddr *mac); > void page_size_init(void); > > +int object_create(void *opaque, QemuOpts *opts, Error **errp); > + > #endif > diff --git a/vl.c b/vl.c > index f043009..b21335e 100644 > --- a/vl.c > +++ b/vl.c > @@ -2819,7 +2819,7 @@ static bool object_create_delayed(const char *type) > } > > > -static int object_create(void *opaque, QemuOpts *opts, Error **errp) > +int object_create(void *opaque, QemuOpts *opts, Error **errp) > { > Error *err = NULL; > char *type = NULL; > @@ -2842,7 +2842,7 @@ static int object_create(void *opaque, QemuOpts *opts, Error **errp) > if (err) { > goto out; > } > - if (!type_predicate(type)) { > + if (type_predicate && !type_predicate(type)) { > goto out; > } >
On 2016/2/1 11:05, Jason Wang wrote: > > > On 01/27/2016 04:29 PM, zhanghailiang wrote: >> Make the helper object_create() public and fix its first >> parameter to accept NULL value. > > Looks not very nice. Maybe pass a new predicate func for sanity check it > better. > OK, but here is it better to check if the predicate func is NULL ? Thanks, Hailiang >> >> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com> >> Cc: Paolo Bonzini <pbonzini@redhat.com> >> --- >> v2: >> - New patch >> --- >> include/qemu-common.h | 2 ++ >> vl.c | 4 ++-- >> 2 files changed, 4 insertions(+), 2 deletions(-) >> >> diff --git a/include/qemu-common.h b/include/qemu-common.h >> index 22b010c..52cf4fd 100644 >> --- a/include/qemu-common.h >> +++ b/include/qemu-common.h >> @@ -500,4 +500,6 @@ int parse_debug_env(const char *name, int max, int initial); >> const char *qemu_ether_ntoa(const MACAddr *mac); >> void page_size_init(void); >> >> +int object_create(void *opaque, QemuOpts *opts, Error **errp); >> + >> #endif >> diff --git a/vl.c b/vl.c >> index f043009..b21335e 100644 >> --- a/vl.c >> +++ b/vl.c >> @@ -2819,7 +2819,7 @@ static bool object_create_delayed(const char *type) >> } >> >> >> -static int object_create(void *opaque, QemuOpts *opts, Error **errp) >> +int object_create(void *opaque, QemuOpts *opts, Error **errp) >> { >> Error *err = NULL; >> char *type = NULL; >> @@ -2842,7 +2842,7 @@ static int object_create(void *opaque, QemuOpts *opts, Error **errp) >> if (err) { >> goto out; >> } >> - if (!type_predicate(type)) { >> + if (type_predicate && !type_predicate(type)) { >> goto out; >> } >> > > > . >
On 02/01/2016 02:19 PM, Hailiang Zhang wrote: > On 2016/2/1 11:05, Jason Wang wrote: >> >> >> On 01/27/2016 04:29 PM, zhanghailiang wrote: >>> Make the helper object_create() public and fix its first >>> parameter to accept NULL value. >> >> Looks not very nice. Maybe pass a new predicate func for sanity check it >> better. >> > > OK, but here is it better to check if the predicate func is NULL ? > > Thanks, > Hailiang Not sure, but if you stick to check against NULL, need a separate patch.
On 2016/2/1 15:27, Jason Wang wrote: > > > On 02/01/2016 02:19 PM, Hailiang Zhang wrote: >> On 2016/2/1 11:05, Jason Wang wrote: >>> >>> >>> On 01/27/2016 04:29 PM, zhanghailiang wrote: >>>> Make the helper object_create() public and fix its first >>>> parameter to accept NULL value. >>> >>> Looks not very nice. Maybe pass a new predicate func for sanity check it >>> better. >>> >> >> OK, but here is it better to check if the predicate func is NULL ? >> >> Thanks, >> Hailiang > > Not sure, but if you stick to check against NULL, need a separate patch. > OK, i will drop this unnecessary check and add sanity check in next version, thanks.
On Wed, Jan 27, 2016 at 04:29:37PM +0800, zhanghailiang wrote: > Make the helper object_create() public and fix its first > parameter to accept NULL value. > > Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com> > Cc: Paolo Bonzini <pbonzini@redhat.com> > --- > v2: > - New patch > --- > include/qemu-common.h | 2 ++ > vl.c | 4 ++-- > 2 files changed, 4 insertions(+), 2 deletions(-) > > diff --git a/include/qemu-common.h b/include/qemu-common.h > index 22b010c..52cf4fd 100644 > --- a/include/qemu-common.h > +++ b/include/qemu-common.h > @@ -500,4 +500,6 @@ int parse_debug_env(const char *name, int max, int initial); > const char *qemu_ether_ntoa(const MACAddr *mac); > void page_size_init(void); > > +int object_create(void *opaque, QemuOpts *opts, Error **errp); > + > #endif > diff --git a/vl.c b/vl.c > index f043009..b21335e 100644 > --- a/vl.c > +++ b/vl.c > @@ -2819,7 +2819,7 @@ static bool object_create_delayed(const char *type) > } > > > -static int object_create(void *opaque, QemuOpts *opts, Error **errp) > +int object_create(void *opaque, QemuOpts *opts, Error **errp) > { > Error *err = NULL; > char *type = NULL; > @@ -2842,7 +2842,7 @@ static int object_create(void *opaque, QemuOpts *opts, Error **errp) > if (err) { > goto out; > } > - if (!type_predicate(type)) { > + if (type_predicate && !type_predicate(type)) { > goto out; > } No, please don't do this - your later patch should *not* be using object_create, it should use object_new_with_props. Regards, Daniel
On 2016/2/1 18:41, Daniel P. Berrange wrote: > On Wed, Jan 27, 2016 at 04:29:37PM +0800, zhanghailiang wrote: >> Make the helper object_create() public and fix its first >> parameter to accept NULL value. >> >> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com> >> Cc: Paolo Bonzini <pbonzini@redhat.com> >> --- >> v2: >> - New patch >> --- >> include/qemu-common.h | 2 ++ >> vl.c | 4 ++-- >> 2 files changed, 4 insertions(+), 2 deletions(-) >> >> diff --git a/include/qemu-common.h b/include/qemu-common.h >> index 22b010c..52cf4fd 100644 >> --- a/include/qemu-common.h >> +++ b/include/qemu-common.h >> @@ -500,4 +500,6 @@ int parse_debug_env(const char *name, int max, int initial); >> const char *qemu_ether_ntoa(const MACAddr *mac); >> void page_size_init(void); >> >> +int object_create(void *opaque, QemuOpts *opts, Error **errp); >> + >> #endif >> diff --git a/vl.c b/vl.c >> index f043009..b21335e 100644 >> --- a/vl.c >> +++ b/vl.c >> @@ -2819,7 +2819,7 @@ static bool object_create_delayed(const char *type) >> } >> >> >> -static int object_create(void *opaque, QemuOpts *opts, Error **errp) >> +int object_create(void *opaque, QemuOpts *opts, Error **errp) >> { >> Error *err = NULL; >> char *type = NULL; >> @@ -2842,7 +2842,7 @@ static int object_create(void *opaque, QemuOpts *opts, Error **errp) >> if (err) { >> goto out; >> } >> - if (!type_predicate(type)) { >> + if (type_predicate && !type_predicate(type)) { >> goto out; >> } > > No, please don't do this - your later patch should *not* be using > object_create, it should use object_new_with_props. > Er, i didn't notice this helper before, i will look into it. Thanks, Hailiang > Regards, > Daniel >
diff --git a/include/qemu-common.h b/include/qemu-common.h index 22b010c..52cf4fd 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -500,4 +500,6 @@ int parse_debug_env(const char *name, int max, int initial); const char *qemu_ether_ntoa(const MACAddr *mac); void page_size_init(void); +int object_create(void *opaque, QemuOpts *opts, Error **errp); + #endif diff --git a/vl.c b/vl.c index f043009..b21335e 100644 --- a/vl.c +++ b/vl.c @@ -2819,7 +2819,7 @@ static bool object_create_delayed(const char *type) } -static int object_create(void *opaque, QemuOpts *opts, Error **errp) +int object_create(void *opaque, QemuOpts *opts, Error **errp) { Error *err = NULL; char *type = NULL; @@ -2842,7 +2842,7 @@ static int object_create(void *opaque, QemuOpts *opts, Error **errp) if (err) { goto out; } - if (!type_predicate(type)) { + if (type_predicate && !type_predicate(type)) { goto out; }
Make the helper object_create() public and fix its first parameter to accept NULL value. Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com> Cc: Paolo Bonzini <pbonzini@redhat.com> --- v2: - New patch --- include/qemu-common.h | 2 ++ vl.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-)