From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754793AbbI3QnO (ORCPT ); Wed, 30 Sep 2015 12:43:14 -0400 Received: from mail-qk0-f171.google.com ([209.85.220.171]:34726 "EHLO mail-qk0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754660AbbI3QnJ (ORCPT ); Wed, 30 Sep 2015 12:43:09 -0400 From: Paul Moore To: Rasmus Villemoes Cc: Stephen Smalley , Eric Paris , James Morris , "Serge E. Hallyn" , selinux@tycho.nsa.gov, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 5/5] selinux: use sprintf return value Date: Wed, 30 Sep 2015 12:43:07 -0400 Message-ID: <1536993.anFU3vzeka@sifl> User-Agent: KMail/4.14.10 (Linux/4.1.5-gentoo; KDE/4.14.12; x86_64; ; ) In-Reply-To: <1443220459-11042-6-git-send-email-linux@rasmusvillemoes.dk> References: <1443220459-11042-1-git-send-email-linux@rasmusvillemoes.dk> <1443220459-11042-6-git-send-email-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Saturday, September 26, 2015 12:34:19 AM Rasmus Villemoes wrote: > sprintf returns the number of characters printed (excluding '\0'), so > we can use that and avoid duplicating the length computation. > > Signed-off-by: Rasmus Villemoes > --- > security/selinux/ss/services.c | 5 +---- > 1 file changed, 1 insertion(+), 4 deletions(-) Applied, thank you. I just pushed all five of your patches to the SELinux next branch so they should be included in the next linux-next release. > diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c > index aa2bdcb20848..ebb5eb3c318c 100644 > --- a/security/selinux/ss/services.c > +++ b/security/selinux/ss/services.c > @@ -1218,13 +1218,10 @@ static int context_struct_to_string(struct context > *context, char **scontext, u3 /* > * Copy the user name, role name and type name into the context. > */ > - sprintf(scontextp, "%s:%s:%s", > + scontextp += sprintf(scontextp, "%s:%s:%s", > sym_name(&policydb, SYM_USERS, context->user - 1), > sym_name(&policydb, SYM_ROLES, context->role - 1), > sym_name(&policydb, SYM_TYPES, context->type - 1)); > - scontextp += strlen(sym_name(&policydb, SYM_USERS, context->user - 1)) + > - 1 + strlen(sym_name(&policydb, SYM_ROLES, context->role - 1)) + > - 1 + strlen(sym_name(&policydb, SYM_TYPES, context->type - 1)); > > mls_sid_to_context(context, &scontextp); -- paul moore www.paul-moore.com