Received: from eggs.gnu.org ([2001:4830:134:3::10]:52319) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGQLe-0000Xa-DX for qemu-devel@nongnu.org; Wed, 28 Jan 2015 05:59:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YGQLb-0004Ja-8v for qemu-devel@nongnu.org; Wed, 28 Jan 2015 05:59:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52976) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGQLb-0004JW-1U for qemu-devel@nongnu.org; Wed, 28 Jan 2015 05:59:47 -0500 From: Markus Armbruster References: <1422376711-31648-1-git-send-email-armbru@redhat.com> <1422376711-31648-4-git-send-email-armbru@redhat.com> <20150127182210.08ae1e38@oc7435384737.ibm.com> Date: Wed, 28 Jan 2015 11:59:42 +0100 In-Reply-To: <20150127182210.08ae1e38@oc7435384737.ibm.com> (Thomas Huth's message of "Tue, 27 Jan 2015 18:22:10 +0100") Message-ID: <8761brtbkx.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH 3/6] kvm: g_malloc() can't fail, bury dead error handling List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Thomas Huth Cc: qemu-trivial@redhat.com, qemu-devel@nongnu.org Thomas Huth writes: > On Tue, 27 Jan 2015 17:38:28 +0100 > Markus Armbruster wrote: > >> Signed-off-by: Markus Armbruster >> --- >> 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.