From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754104AbbEKOlS (ORCPT ); Mon, 11 May 2015 10:41:18 -0400 Received: from mail.kernel.org ([198.145.29.136]:44817 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751825AbbEKOlO (ORCPT ); Mon, 11 May 2015 10:41:14 -0400 Date: Mon, 11 May 2015 11:41:10 -0300 From: Arnaldo Carvalho de Melo To: Namhyung Kim Cc: Ingo Molnar , Peter Zijlstra , Jiri Olsa , LKML , David Ahern , Joonsoo Kim , Minchan Kim , Pekka Enberg , linux-mm@kvack.org Subject: Re: [PATCH 4/6] perf kmem: Print gfp flags in human readable string Message-ID: <20150511144110.GR28183@kernel.org> References: <1429592107-1807-1-git-send-email-namhyung@kernel.org> <1429592107-1807-5-git-send-email-namhyung@kernel.org> <20150511143536.GP28183@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20150511143536.GP28183@kernel.org> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Mon, May 11, 2015 at 11:35:36AM -0300, Arnaldo Carvalho de Melo escreveu: > Em Tue, Apr 21, 2015 at 01:55:05PM +0900, Namhyung Kim escreveu: > > Save libtraceevent output and print it in the header. > > > > > +static int parse_gfp_flags(struct perf_evsel *evsel, struct perf_sample *sample, > > + unsigned int gfp_flags) > > +{ > > + char *str, *pos; > > + str = strtok_r(seq.buffer, " ", &pos); > > builtin-kmem.c:743:427: error: ‘pos’ may be used uninitialized in this > function [-Werror=maybe-uninitialized] > new->human_readable = strdup(str + 10); > ^ > builtin-kmem.c:716:14: note: ‘pos’ was declared here > char *str, *pos; > ^ Emphasis on the "may", as according to strtok_r your code is ok, its just the compiler that needs to be told that no, it is not being accessed uninitialized: On the first call to strtok_r(), str should point to the string to be parsed, and the value of saveptr is ignored. In subsequent calls, str should be NULL, and saveptr should be unchanged since the previous call. So just setting it to NULL is enough. - Arnaldo