Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754202AbbFCKbw (ORCPT ); Wed, 3 Jun 2015 06:31:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45747 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754107AbbFCKbZ (ORCPT ); Wed, 3 Jun 2015 06:31:25 -0400 Date: Wed, 3 Jun 2015 12:31:19 +0200 From: Jiri Olsa To: Sukadev Bhattiprolu Cc: mingo@redhat.com, ak@linux.intel.com, Michael Ellerman , Arnaldo Carvalho de Melo , namhyung@kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v13 02/14] perf, tools, jevents: Program to convert JSON file to C style file Message-ID: <20150603103119.GF1828@krava.redhat.com> References: <1433265135-20426-1-git-send-email-sukadev@linux.vnet.ibm.com> <1433265135-20426-3-git-send-email-sukadev@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1433265135-20426-3-git-send-email-sukadev@linux.vnet.ibm.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 Content-Length: 1397 Lines: 58 On Tue, Jun 02, 2015 at 10:12:02AM -0700, Sukadev Bhattiprolu wrote: SNIP > + * If we fail to locate/process JSON and map files, create a NULL mapping > + * table. This would at least allow perf to build even if we can't find/use > + * the aliases. > + */ > +static void create_empty_mapping(const char *output_file) > +{ > + FILE *outfp; > + > + pr_info("%s: Creating empty pmu_events_map[] table\n", prog); > + > + /* Unlink file to clear any partial writes to it */ > + unlink(output_file); > + > + outfp = fopen(output_file, "a"); you could open with "w+" and save the unlink call SNIP > +int main(int argc, char *argv[]) > +{ > + int rc; > + int flags; > + int maxfds; > + char dirname[PATH_MAX]; > + > + const char *arch; > + const char *output_file; > + const char *start_dirname; > + > + prog = basename(argv[0]); > + if (argc < 4) { > + pr_err("Usage: %s \n", prog); > + return 1; > + } > + > + arch = argv[1]; > + start_dirname = argv[2]; > + output_file = argv[3]; > + > + if (argc > 4) > + verbose = atoi(argv[4]); > + > + unlink(output_file); > + eventsfp = fopen(output_file, "a"); ditto SNIP -- 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/