Message ID | 1422376711-31648-4-git-send-email-armbru@redhat.com |
---|---|
State | New |
Headers | show |
On Tue, 27 Jan 2015 17:38:28 +0100 Markus Armbruster <armbru@redhat.com> wrote: > Signed-off-by: Markus Armbruster <armbru@redhat.com> > --- > kvm-all.c | 4 ---- > 1 file changed, 4 deletions(-) > > diff --git a/kvm-all.c b/kvm-all.c > index 2f21a4e..05a79c2 100644 > --- a/kvm-all.c > +++ b/kvm-all.c > @@ -2070,10 +2070,6 @@ int kvm_insert_breakpoint(CPUState *cpu, target_ulong addr, > } > > bp = g_malloc(sizeof(struct kvm_sw_breakpoint)); > - if (!bp) { > - return -ENOMEM; > - } > - > bp->pc = addr; > bp->use_count = 1; > err = kvm_arch_insert_sw_breakpoint(cpu, bp); I think I'd also use g_try_malloc() here instead. Looks like an error gets reported to GDB when this function returns with an error code, so returning -ENOMEM should be ok here, shouldn't it? Thomas
Thomas Huth <thuth@linux.vnet.ibm.com> writes: > On Tue, 27 Jan 2015 17:38:28 +0100 > Markus Armbruster <armbru@redhat.com> wrote: > >> Signed-off-by: Markus Armbruster <armbru@redhat.com> >> --- >> kvm-all.c | 4 ---- >> 1 file changed, 4 deletions(-) >> >> diff --git a/kvm-all.c b/kvm-all.c >> index 2f21a4e..05a79c2 100644 >> --- a/kvm-all.c >> +++ b/kvm-all.c >> @@ -2070,10 +2070,6 @@ int kvm_insert_breakpoint(CPUState *cpu, target_ulong addr, >> } >> >> bp = g_malloc(sizeof(struct kvm_sw_breakpoint)); >> - if (!bp) { >> - return -ENOMEM; >> - } >> - >> bp->pc = addr; >> bp->use_count = 1; >> err = kvm_arch_insert_sw_breakpoint(cpu, bp); > > I think I'd also use g_try_malloc() here instead. Looks like an error > gets reported to GDB when this function returns with an error code, so > returning -ENOMEM should be ok here, shouldn't it? Same rationale as for PATCH 2. sizeof(struct kvm_sw_breakpoint) is 40 bytes on my system.
diff --git a/kvm-all.c b/kvm-all.c index 2f21a4e..05a79c2 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -2070,10 +2070,6 @@ int kvm_insert_breakpoint(CPUState *cpu, target_ulong addr, } bp = g_malloc(sizeof(struct kvm_sw_breakpoint)); - if (!bp) { - return -ENOMEM; - } - bp->pc = addr; bp->use_count = 1; err = kvm_arch_insert_sw_breakpoint(cpu, bp);
Signed-off-by: Markus Armbruster <armbru@redhat.com> --- kvm-all.c | 4 ---- 1 file changed, 4 deletions(-)