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: 6702301 Return-Path: X-Original-To: patchwork-linux-fbdev@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 522D7C05AD for ; Wed, 1 Jul 2015 09:44:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8F91F2066C for ; Wed, 1 Jul 2015 09:44:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A58752066E for ; Wed, 1 Jul 2015 09:44:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753844AbbGAJnx (ORCPT ); Wed, 1 Jul 2015 05:43:53 -0400 Received: from mail-wg0-f52.google.com ([74.125.82.52]:35655 "EHLO mail-wg0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752220AbbGAJmg (ORCPT ); Wed, 1 Jul 2015 05:42:36 -0400 Received: by wgjx7 with SMTP id x7so31628254wgj.2; 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 Cc: Mark Brown , linux-acpi@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-pwm@vger.kernel.org, "Rafael J. Wysocki" , alsa-devel@alsa-project.org, Tomeu Vizoso 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> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,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);