From owner-freebsd-hackers@FreeBSD.ORG Sun Mar 17 09:19:45 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 14202B27; Sun, 17 Mar 2013 09:19:45 +0000 (UTC) (envelope-from to.my.trociny@gmail.com) Received: from mail-wg0-f48.google.com (mail-wg0-f48.google.com [74.125.82.48]) by mx1.freebsd.org (Postfix) with ESMTP id EE43A8C7; Sun, 17 Mar 2013 09:19:43 +0000 (UTC) Received: by mail-wg0-f48.google.com with SMTP id 16so4215061wgi.27 for ; Sun, 17 Mar 2013 02:19:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=tvEzqT5ICUdfJ/vbhwhV3y4+ODOOkKK9cCBjN+GZIC4=; b=JwhY2oWknd9p4nfbYc+2fpLIJ5CaWX5rEmzJv5Ut4xL0oVvfdAiBWGG75s1B+4EhFW 1lNDYgSvTRPG18xZlph32klcUGG5SueqKD6OaFPs4b/0rbMSuKGFcPDRDloR2FSCHyld 0Mu6kKLuIfFyECDo9HYmZo9RymttTx1Z5TGou7+YMyuh0/Vovtemoc6wgr7+csUOqVjT FfkKqAIzXGJOsbgFlpveuOk66eyfWQgpWAIRMVZNeCdLLxJFmADzAAUeCpSZl2NBkq7P kXAkUlL/KZnvnqE79rAW6FJfrvWZB3sqc3/XTXNNIb7+TbgKSVnfWAa1H2vEiRkVMJHv xUXA== X-Received: by 10.194.237.40 with SMTP id uz8mr18956402wjc.49.1363511976696; Sun, 17 Mar 2013 02:19:36 -0700 (PDT) Received: from localhost ([178.150.115.244]) by mx.google.com with ESMTPS id fx5sm8019257wib.11.2013.03.17.02.19.34 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 17 Mar 2013 02:19:35 -0700 (PDT) Sender: Mikolaj Golub Date: Sun, 17 Mar 2013 11:19:32 +0200 From: Mikolaj Golub To: Konstantin Belousov Subject: Re: libprocstat(3): retrieve process command line args and environment Message-ID: <20130317091930.GA2833@gmail.com> References: <20130119151253.GB88025@gmail.com> <201301251531.43540.jhb@freebsd.org> <20130212215054.GA9839@gmail.com> <201302200904.15324.jhb@freebsd.org> <20130220195801.GA8679@gmail.com> <20130316180915.GA91146@gmail.com> <20130316191605.GJ3794@kib.kiev.ua> <20130316223339.GA3534@gmail.com> <20130317063033.GL3794@kib.kiev.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130317063033.GL3794@kib.kiev.ua> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Stanislav Sedov , Attilio Rao , "Robert N. M. Watson" , freebsd-hackers@freebsd.org X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Mar 2013 09:19:45 -0000 On Sun, Mar 17, 2013 at 08:30:33AM +0200, Konstantin Belousov wrote: > On Sun, Mar 17, 2013 at 12:35:20AM +0200, Mikolaj Golub wrote: > > A KPI that would be natural for my case: > > > > /* start a section that is going to be aligned to sizeof(Elf_Size), > > using byte '0' for padding */ > > sbuf_padded_start(sb, sizeof(Elf_Size), 0); > > /* write something to sbuf */ > > sbuf_bcat(sb, data, len); > > /* align the sbuf section */ > > sbuf_pad(sb); > > > > This might look a little awkward and would add some overhead for the normal > > case though... > This looks fine, in fact. You might want to call it sbuf_start_section() > and sbuf_end_section() ? Ok, will try this way. Thanks. ... > All you need is to reset req->oldidx. This could be done outside the > sbuf interface, in the top level function implementing the sysctl ? I am afraid at this level I don't know a value to reset req->oldidx to. Reseting it to 0 I think is not a good solution? > What you propose in the follow-up message should work too, I do not > have any preference. Ok. Thanks. > > > Indents after the else clauses in kern_proc_out() are wrong. > > > > Do you mean indents after '#ifdef COMPAT_FREEBSD32' block? I did it > > that way so if COMPAT_FREEBSD32 sections were removed from the code > > the indentation would be correct. I saw this practice through the code > > and used it myself before. > The sections are not going to be removed. IMHO code should be formatted > as if the preprocessor directive lines are not present. Could you point > out an example of existing code consistent with your indentation ? In kern/kern_proc.c my code (get_proc_vector, sysctl_kern_proc_auxv) has such indentation. There were no objection when I introduced it, so I thought it was a right way. But surely I didn't invented such indentation myself. I don't recall if I used some particular examples as a reference then, but here are several examples of such indentation found by quick grep: net/bpf.c-#ifdef BPF_JITTER net/bpf.c- bf = bpf_jitter_enable != 0 ? d->bd_bfilter : NULL; net/bpf.c- if (bf != NULL) net/bpf.c- slen = (*(bf->func))(pkt, pktlen, pktlen); net/bpf.c- else net/bpf.c:#endif net/bpf.c- slen = bpf_filter(d->bd_rfilter, pkt, pktlen, pktlen); kern/kern_conf.c-#if 0 kern/kern_conf.c- if (dev->si_usecount == 0 && kern/kern_conf.c- (dev->si_flags & SI_CHEAPCLONE) && (dev->si_flags & SI_NAMED)) kern/kern_conf.c- ; kern/kern_conf.c- else kern/kern_conf.c:#endif kern/kern_conf.c- if (dev->si_devsw == NULL && dev->si_refcount == 0) { kern/kern_jail.c- if (SV_PROC_FLAG(td->td_proc, SV_ILP32)) { kern/kern_jail.c- uint32_t hid32 = pr->pr_hostid; kern/kern_jail.c- kern/kern_jail.c- error = vfs_setopt(opts, "host.hostid", &hid32, sizeof(hid32)); kern/kern_jail.c- } else kern/kern_jail.c:#endif kern/kern_jail.c- error = vfs_setopt(opts, "host.hostid", &pr->pr_hostid, netinet6/raw_ip6.c- /* Do not inject data into pcb. */ netinet6/raw_ip6.c- INP_RUNLOCK(last); netinet6/raw_ip6.c- } else netinet6/raw_ip6.c:#endif /* IPSEC */ netinet6/raw_ip6.c- if (last != NULL) { netinet6/raw_ip6.c- if (last->inp_flags & INP_CONTROLOPTS || On the other hand there are many examples where indentation is used in the way you prefer. I don't have any strong opinion about this so I will do in the way you suggest. -- Mikolaj Golub