Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753717AbbGAMBB (ORCPT ); Wed, 1 Jul 2015 08:01:01 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:49176 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751276AbbGAMAy (ORCPT ); Wed, 1 Jul 2015 08:00:54 -0400 Subject: Re: [PATCH 4/4] perf probe: Add failure check when show variable range To: Masami Hiramatsu , , , , , References: <1435741539-44100-1-git-send-email-hekuang@huawei.com> <1435741539-44100-4-git-send-email-hekuang@huawei.com> <5593C843.6000200@hitachi.com> CC: , From: He Kuang Message-ID: <5593D65A.9000906@huawei.com> Date: Wed, 1 Jul 2015 20:00:26 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.0 MIME-Version: 1.0 In-Reply-To: <5593C843.6000200@hitachi.com> Content-Type: text/plain; charset="iso-2022-jp" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.110.54.65] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2356 Lines: 78 hi, Masami On 2015/7/1 19:00, Masami Hiramatsu wrote: > On 2015/07/01 18:05, He Kuang wrote: >> Change improper type size_t to diffptr_t to make consistent with libdw >> and handle error code. >> >> Signed-off-by: He Kuang >> --- >> tools/perf/util/dwarf-aux.c | 10 ++++++++-- >> 1 file changed, 8 insertions(+), 2 deletions(-) >> >> diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c >> index 2cb4c82..da96eb1 100644 >> --- a/tools/perf/util/dwarf-aux.c >> +++ b/tools/perf/util/dwarf-aux.c >> @@ -965,7 +965,7 @@ static int die_get_var_innermost_scope(Dwarf_Die *sp_die, Dwarf_Die *vr_die, >> { >> Dwarf_Die *scopes; >> int count; >> - size_t offset = 0; >> + ptrdiff_t offset = 0; >> Dwarf_Addr base; >> Dwarf_Addr start, end; >> Dwarf_Addr entry; >> @@ -991,6 +991,9 @@ static int die_get_var_innermost_scope(Dwarf_Die *sp_die, Dwarf_Die *vr_die, >> >> while ((offset = dwarf_ranges(&scopes[1], offset, &base, >> &start, &end)) > 0) { >> + if (offset < 0) >> + goto out; > > Hmm, here offset always > 0, see the condition carefully. > Perhaps, this should be placed at the right after the while loop. Sorry for this silly mistake. Modified and resent with patch 3/4, more info is added in commit message of that patch. Thank you. > >> + >> start -= entry; >> end -= entry; >> >> @@ -1029,7 +1032,7 @@ int die_get_var_range(Dwarf_Die *sp_die, Dwarf_Die *vr_die, struct strbuf *buf) >> Dwarf_Addr entry; >> Dwarf_Op *op; >> size_t nops; >> - size_t offset = 0; >> + ptrdiff_t offset = 0; >> Dwarf_Attribute attr; >> bool first = true; >> const char *name; >> @@ -1048,6 +1051,9 @@ int die_get_var_range(Dwarf_Die *sp_die, Dwarf_Die *vr_die, struct strbuf *buf) >> while ((offset = dwarf_getlocations( >> &attr, offset, &base, >> &start, &end, &op, &nops)) > 0) { >> + if (offset < 0) >> + return offset; > > Ditto. > > Thanks, > >> + >> if (start == 0) { >> /* Single Location Descriptions */ >> ret = die_get_var_innermost_scope(sp_die, vr_die, buf); >> > > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/