From 75f210fdb997e7c91d65254ca46af1c30383fc74 Mon Sep 17 00:00:00 2001 From: Nathan Hjelm Date: Thu, 9 Apr 2015 11:51:36 -0600 Subject: [PATCH] opal/util/error: check for existing convertor for error range This commit fixes a bug when opal_error_init is called with the same values multiple times. If opal_error_init is called too many times it will start failing with OPAL_ERR_OUT_OF_RESOURCE. To fix the problem check if an existing convertor matching the requested one and return that one instead. Signed-off-by: Nathan Hjelm --- opal/util/error.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/opal/util/error.c b/opal/util/error.c index fb948bfd746..e8a631c8d84 100644 --- a/opal/util/error.c +++ b/opal/util/error.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana * University Research and Technology @@ -9,8 +10,8 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. - * Copyright (c) 2007-2012 Los Alamos National Security, LLC. - * All rights reserved. + * Copyright (c) 2007-2015 Los Alamos National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -199,6 +200,11 @@ opal_error_register(const char *project, int err_base, int err_max, converters[i].err_max = err_max; converters[i].converter = converter; return OPAL_SUCCESS; + } else if (converters[i].err_base == err_base && + converters[i].err_max == err_max && + !strcmp (project, converters[i].project)) { + converters[i].converter = converter; + return OPAL_SUCCESS; } }