From owner-svn-src-all@FreeBSD.ORG Wed Mar 11 00:01:40 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id BC997F6C; Wed, 11 Mar 2015 00:01:40 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8E2C1982; Wed, 11 Mar 2015 00:01:40 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t2B01eWO026625; Wed, 11 Mar 2015 00:01:40 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t2B01euw026624; Wed, 11 Mar 2015 00:01:40 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201503110001.t2B01euw026624@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Wed, 11 Mar 2015 00:01:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r279869 - head/cddl/contrib/opensolaris/common/ctf X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Mar 2015 00:01:40 -0000 Author: markj Date: Wed Mar 11 00:01:39 2015 New Revision: 279869 URL: https://svnweb.freebsd.org/changeset/base/279869 Log: When copying a type from a source CTF container to a destination container, ctf_add_type() first performs a by-name lookup of the type in the destination container. If this lookup returns a forward declaration for an enum, struct, or union, reset dst_type back to CTF_ERR, indicating that the source type is not in fact present in the destination container. This ensures that ctf_add_type() will also search the destination container's dynamic type list for the source type. Without this change, a pair of mutually recursive struct definitions could cause infinite recursion in ctf_add_type() if the destination container only contained forward declarations for the struct types: ctf_add_type() recursively calls itself on each struct member's type, and the forward declarations meant that the dynamic type list search would be skipped. MFC after: 2 weeks Sponsored by: EMC / Isilon Storage Division Modified: head/cddl/contrib/opensolaris/common/ctf/ctf_create.c Modified: head/cddl/contrib/opensolaris/common/ctf/ctf_create.c ============================================================================== --- head/cddl/contrib/opensolaris/common/ctf/ctf_create.c Tue Mar 10 23:27:13 2015 (r279868) +++ head/cddl/contrib/opensolaris/common/ctf/ctf_create.c Wed Mar 11 00:01:39 2015 (r279869) @@ -1313,10 +1313,13 @@ ctf_add_type(ctf_file_t *dst_fp, ctf_fil * unless dst_type is a forward declaration and src_type is a struct, * union, or enum (i.e. the definition of the previous forward decl). */ - if (dst_type != CTF_ERR && dst_kind != kind && ( - dst_kind != CTF_K_FORWARD || (kind != CTF_K_ENUM && - kind != CTF_K_STRUCT && kind != CTF_K_UNION))) - return (ctf_set_errno(dst_fp, ECTF_CONFLICT)); + if (dst_type != CTF_ERR && dst_kind != kind) { + if (dst_kind != CTF_K_FORWARD || (kind != CTF_K_ENUM && + kind != CTF_K_STRUCT && kind != CTF_K_UNION)) + return (ctf_set_errno(dst_fp, ECTF_CONFLICT)); + else + dst_type = CTF_ERR; + } /* * If the non-empty name was not found in the appropriate hash, search