Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp59973imj; Thu, 14 Feb 2019 15:20:11 -0800 (PST) X-Google-Smtp-Source: AHgI3IZE+siCvUhq5SyieFGynwr84YghpQwuNGWyR7KH50o4ubzHL1wc9TIq/sISuZ1NKFplKXVS X-Received: by 2002:a63:5153:: with SMTP id r19mr2385591pgl.281.1550186411695; Thu, 14 Feb 2019 15:20:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550186411; cv=none; d=google.com; s=arc-20160816; b=UEPvWeogw2KBHdVzGFJMmRx8SyGxqzVWy7VH7clu79CADtTX8Zxfhdlbt/riFpUmTh t5oCa3UaqY9OPvDFR6+WmWGCwM+cWSYdmEo/2/WcCeoIARmZPyHZIRbjtp/tBYzLVvQ0 wcSFyLihOoGi03vWcknL5xUc9uXUPSiRA69oyhpZgj/ehXhjOMHv2ZmEwrxKopsSJTVQ weQAQqJc3EwYfAgobPEBHvvpKV1xzO+tso5B/zy1O24idYY3aGRNO3n80r/xE2fLMTI/ cT25ViXSWF0e1gfQXxX1yNEjYvsLqtjPAG28Ze3G12+HOJDDSqaALjW2pe451h3Hyujr LsgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=g1ujKF29ImiOUijbLT3DEzHdI0tRuu2tGdaQlV3Mxoo=; b=tYpS6OEDydkMWqIRRCg6YsF/q6w9ig9F+zCHM7VjYRgN52zVBrMlqhjgYiT3ZONQsB jTzhLsBDKpQctKwHD9u8a9Tgsddusi0dEpKWfXFvmiMxH+mc2MWNYgyl2B9CJeYa21XQ Z0plZCuJ6/ktiP+lyeTbBc4GD5xLGIO2tD4xnxpM0Q5et9hezd/QqNsSg2oIvJclOJEZ jnQDEmhMw28WA6kiRlnBjM8zalm+EqKikO5uXG4XlntsJDySVKlegGFiANhQBZ/gQjah Fb4OEAMXz/48mGQZKPueq9pVj/OSRGipbSWxttWi7u91oZpoH7QzJVnMXteU7KX9Nx1/ FgPg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j1si3409039pgp.449.2019.02.14.15.19.56; Thu, 14 Feb 2019 15:20:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438556AbfBNMxx (ORCPT + 99 others); Thu, 14 Feb 2019 07:53:53 -0500 Received: from mga17.intel.com ([192.55.52.151]:54566 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388534AbfBNMxw (ORCPT ); Thu, 14 Feb 2019 07:53:52 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Feb 2019 04:53:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,368,1544515200"; d="scan'208";a="275034467" Received: from smile.fi.intel.com (HELO smile) ([10.237.72.86]) by orsmga004.jf.intel.com with ESMTP; 14 Feb 2019 04:53:48 -0800 Received: from andy by smile with local (Exim 4.92-RC6) (envelope-from ) id 1guGWR-0003K3-3S; Thu, 14 Feb 2019 14:53:47 +0200 Date: Thu, 14 Feb 2019 14:53:47 +0200 From: Andy Shevchenko To: Xiang Xiao Cc: rdunlap@infradead.org, gregkh@linuxfoundation.org, alexander.shishkin@linux.intel.com, ohad@wizery.com, bjorn.andersson@linaro.org, wendy.liang@xilinx.com, arnaud.pouliquen@st.com, kumar.gala@linaro.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Xiang Xiao Subject: Re: [PATCH V2 1/2] lib/string: add memrchr function Message-ID: <20190214125347.GU9224@smile.fi.intel.com> References: <1550124158-1111-1-git-send-email-xiaoxiang@xiaomi.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1550124158-1111-1-git-send-email-xiaoxiang@xiaomi.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 14, 2019 at 02:02:37PM +0800, Xiang Xiao wrote: > Here is the detailed description for memrchr: > > void *memrchr(const void *s, int c, size_t n); > > The memrchr() function is like the memchr() function, except > that it searches backward from the end of the n bytes pointed > to by s instead of forward from the beginning. > > The memrchr() functions return a pointer to the matching byte > or NULL if the character does not occur in the given memory > area. > +void *memrchr(const void *s, int c, size_t n) > +{ > + const unsigned char *p = s + n; > + > + while (n-- != 0) { Simple: while (n--) { > + if ((unsigned char)c == *--p) > + return (void *)p; > + } > + return NULL; > +} -- With Best Regards, Andy Shevchenko