From patchwork Wed Oct 18 22:31:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Programmingkid X-Patchwork-Id: 10015387 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DDABB60215 for ; Wed, 18 Oct 2017 22:32:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D031D286D1 for ; Wed, 18 Oct 2017 22:32:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C361D28B1A; Wed, 18 Oct 2017 22:32:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0095C28C15 for ; Wed, 18 Oct 2017 22:32:46 +0000 (UTC) Received: from localhost ([::1]:46770 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4wtJ-00018b-CD for patchwork-qemu-devel@patchwork.kernel.org; Wed, 18 Oct 2017 18:32:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40813) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4wsJ-00017G-Bv for qemu-devel@nongnu.org; Wed, 18 Oct 2017 18:31:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e4wsE-0005GJ-El for qemu-devel@nongnu.org; Wed, 18 Oct 2017 18:31:43 -0400 Received: from mail-io0-x244.google.com ([2607:f8b0:4001:c06::244]:54569) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e4wsE-0005DO-9O; Wed, 18 Oct 2017 18:31:38 -0400 Received: by mail-io0-x244.google.com with SMTP id e89so7913311ioi.11; Wed, 18 Oct 2017 15:31:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=J5DEFGm35jtwh+YJqpOSZNFQtLjJ+BRleKjdLRY2OYU=; b=fBRxDuYQyOgG5eh6zqdTxKPmuWlqH11g96+Zmn74ajN1nAg2yj0xUywNGHKnAlntRA saLaTiIM1ik1zDemzdB16N/pAQ0SQW17kFnS0jLT2E68CqbHtxIiXpWFajOk6maAyDX9 SCwxWvhmJF2T8D3m/tKggg95YXtmx3tjYFuNIaqA2WocT8IblKpNHJM9R0NSdMLyl7f7 NF71KZYX4V1TxT/oq1DcnJLob5FHlu4pi8KnxztUhAlaKZJrQJk0PtA94wPqFCGmoAZN 8V4Ct/sUOo1R9BKc+BVBXYkEONk5l9oUaBG5iKv/eomtto66T8hbLxuMiouk2339WiqV qrxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=J5DEFGm35jtwh+YJqpOSZNFQtLjJ+BRleKjdLRY2OYU=; b=oR9j9zr1fhmvtiQLDDRjDdMAwRzMmz1ZWbHiwSRQIvwrVn5Uy/RVVxMVYpXkmpOyT8 txMtqqxC2qqpRG5DKLd62Gmisd8MfzKclJqocyNHv0/+0awjEB+Nfuc1zc6bs/VXTNPY 6qAVFMVlZaEbZzIn5HXlAnL+XbEj75VFs0GRV/lbdy05RuRXxatDx+o2Rsb1KPNg9E2X RhhmebttXPU37Vwo/aJLon1Ku7tkfdbQSjrOZ008+8sC94kiFTaMYQ0QaPW7iB5nvFRP m5hKnc9NsE74iqzCirq4CzLPga/pdcQZ5ZjSy5De9m4eBxVLPGRtD9/Y3AQzKu4mj8IX sC8A== X-Gm-Message-State: AMCzsaVcHtR3beq5Lftqx2nscYxx8TP8MXfopDrENuf8WA4OnMfJpKAT xbGvE5qSFqAEQKQ5eRiwmoON6Q== X-Google-Smtp-Source: ABhQp+QPAfELvmMvbBThE96BPORyAGJ06qErizj1p7A/F3UsIoVfMa3D+yoQVswADqgRZbQ8cCU8fg== X-Received: by 10.107.147.131 with SMTP id v125mr119148iod.240.1508365895997; Wed, 18 Oct 2017 15:31:35 -0700 (PDT) Received: from localhost.localdomain (d14-69-20-184.try.wideopenwest.com. [69.14.184.20]) by smtp.gmail.com with ESMTPSA id z71sm6263468ioz.27.2017.10.18.15.31.34 (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 18 Oct 2017 15:31:35 -0700 (PDT) From: John Arbuckle To: qemu-devel@nongnu.org, david@gibson.dropbear.id.au, qemu-ppc@nongnu.org Date: Wed, 18 Oct 2017 18:31:16 -0400 Message-Id: <20171018223116.6035-1-programmingkidx@gmail.com> X-Mailer: git-send-email 2.13.5 (Apple Git-94) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4001:c06::244 Subject: [Qemu-devel] [PATCH] fdt_ro.c: implement strnlen X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Arbuckle Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Implement the strnlen() function if it isn't implemented. Signed-off-by: John Arbuckle --- libfdt/fdt_ro.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/libfdt/fdt_ro.c b/libfdt/fdt_ro.c index 3d00d2e..a7986fb 100644 --- a/libfdt/fdt_ro.c +++ b/libfdt/fdt_ro.c @@ -55,6 +55,30 @@ #include "libfdt_internal.h" +/* if the current environment does not define strnlen */ +#ifndef strnlen + +/* This eliminates the missing prototype warning */ +int strnlen(const char *string, int max_count); + +/* + * strnlen: return the length of a string or max_count + * which ever is shortest + */ + +int strnlen(const char *string, int max_count) +{ + int count; + for(count = 0; count < max_count; count++) { + if (string[count] == '\0') { + break; + } + } + return count; +} + +#endif /* strnlen */ + static int _fdt_nodename_eq(const void *fdt, int offset, const char *s, int len) {