From patchwork Wed Jul 1 09:40:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 6701921 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 66C52C05AC for ; Wed, 1 Jul 2015 09:42:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B42762062A for ; Wed, 1 Jul 2015 09:42:38 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 4C46320685 for ; Wed, 1 Jul 2015 09:42:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BE0F86EAA7; Wed, 1 Jul 2015 02:42:36 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wg0-f46.google.com (mail-wg0-f46.google.com [74.125.82.46]) by gabe.freedesktop.org (Postfix) with ESMTPS id 605306EAAD for ; Wed, 1 Jul 2015 02:42:35 -0700 (PDT) Received: by wguu7 with SMTP id u7so31659080wgu.3 for ; Wed, 01 Jul 2015 02:42:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=KjB17NAUMt54dFZFn5KsJcPb9ZQ4UZ6JZji0WtOSMtc=; b=f8XcRACMnWx1VA3XjQGYRdIAh/jSvAf+gVSDkarN4vqtSdHEyysBJU9NwRapcWL34m dHObFJ14HApeowes27y9HJB6uiJMowy5ARx0Tsgo2pK+riFqoPEpWGcPFn+yehbdbdZl aklWFHqDu6bdPUu37uPklkALBSiIy5bXdHWrMLlVB4JILKfcu2akINLzrZ2DtQXuzl6H 4eBasZQxT5t8TqTNaescPheEvhS7K8ut7GD0MhKwrNEd7UV7/N48l22UW7A8lzI5vAxn cMEZTn9ytoysGEVePTXMy29GdqPwhle47V5YgIM1qRKc2OuxDlGNQQQoH8DRby26uJR0 BF0w== X-Received: by 10.194.79.225 with SMTP id m1mr60877wjx.8.1435743753967; Wed, 01 Jul 2015 02:42:33 -0700 (PDT) Received: from cizrna.lan ([109.72.12.160]) by mx.google.com with ESMTPSA id x10sm1992663wjr.25.2015.07.01.02.42.32 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Jul 2015 02:42:32 -0700 (PDT) From: Tomeu Vizoso To: linux-kernel@vger.kernel.org Subject: [PATCH v2 03/12] string: Introduce strends() Date: Wed, 1 Jul 2015 11:40:58 +0200 Message-Id: <1435743667-11987-4-git-send-email-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 2.4.1 In-Reply-To: <1435743667-11987-1-git-send-email-tomeu.vizoso@collabora.com> References: <1435743667-11987-1-git-send-email-tomeu.vizoso@collabora.com> Cc: devicetree@vger.kernel.org, linux-fbdev@vger.kernel.org, Tomeu Vizoso , linux-gpio@vger.kernel.org, "Rafael J. Wysocki" , alsa-devel@alsa-project.org, dri-devel@lists.freedesktop.org, linux-acpi@vger.kernel.org, Mark Brown , linux-pwm@vger.kernel.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP To avoid duplicating code in upcoming patches that will check for postfixes in strings, add strends(). Signed-off-by: Tomeu Vizoso --- Changes in v2: - Move strends to string.h include/linux/string.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/linux/string.h b/include/linux/string.h index d5dfe3e..4244363 100644 --- a/include/linux/string.h +++ b/include/linux/string.h @@ -146,6 +146,19 @@ static inline bool strstarts(const char *str, const char *prefix) return strncmp(str, prefix, strlen(prefix)) == 0; } +/** + * strends - does @str end with @postfix? + * @str: string to examine + * @postfix: postfix to look for + */ +static inline bool strends(const char *str, const char *postfix) +{ + if (strlen(str) < strlen(postfix)) + return false; + + return strcmp(str + strlen(str) - strlen(postfix), postfix) == 0; +} + size_t memweight(const void *ptr, size_t bytes); void memzero_explicit(void *s, size_t count);