From owner-freebsd-hackers@freebsd.org Fri Mar 25 00:15:32 2016 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 57AA6ADB5BF; Fri, 25 Mar 2016 00:15:32 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id 3AFBF1330; Fri, 25 Mar 2016 00:15:32 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from mail.xzibition.com (localhost [IPv6:::1]) by freefall.freebsd.org (Postfix) with ESMTP id 35288123A; Fri, 25 Mar 2016 00:15:32 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from mail.xzibition.com (localhost [172.31.3.2]) by mail.xzibition.com (Postfix) with ESMTP id BAAB720142; Fri, 25 Mar 2016 00:15:31 +0000 (UTC) X-Virus-Scanned: amavisd-new at mail.xzibition.com Received: from mail.xzibition.com ([172.31.3.2]) by mail.xzibition.com (mail.xzibition.com [172.31.3.2]) (amavisd-new, port 10026) with LMTP id qePsuLXOybcP; Fri, 25 Mar 2016 00:15:28 +0000 (UTC) Subject: Re: Code Formatter for STYLE(9)? DKIM-Filter: OpenDKIM Filter v2.9.2 mail.xzibition.com 4CD8F2013C To: Pietro Cerutti , Matthew Seaman References: <56F3EBB1.1060603@embedded-brains.de> <56F3FFB3.6070801@FreeBSD.org> <1fc0f5efcc94822f7f5ca9bbcb850faf@gahr.ch> Cc: freebsd-hackers@freebsd.org, owner-freebsd-hackers@freebsd.org From: Bryan Drewery Openpgp: id=F9173CB2C3AAEA7A5C8A1F0935D771BB6E4697CF; url=http://www.shatow.net/bryan/bryan2.asc Organization: FreeBSD Message-ID: <56F48322.9030208@FreeBSD.org> Date: Thu, 24 Mar 2016 17:15:30 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <1fc0f5efcc94822f7f5ca9bbcb850faf@gahr.ch> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="tQwMehaBEknFFUx9HPnPrg81RIpWiGnGg" X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Mar 2016 00:15:32 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --tQwMehaBEknFFUx9HPnPrg81RIpWiGnGg Content-Type: multipart/mixed; boundary="NQG1e4DpeKdiMcLQlCH5V46sx6sKovkcl" From: Bryan Drewery To: Pietro Cerutti , Matthew Seaman Cc: freebsd-hackers@freebsd.org, owner-freebsd-hackers@freebsd.org Message-ID: <56F48322.9030208@FreeBSD.org> Subject: Re: Code Formatter for STYLE(9)? References: <56F3EBB1.1060603@embedded-brains.de> <56F3FFB3.6070801@FreeBSD.org> <1fc0f5efcc94822f7f5ca9bbcb850faf@gahr.ch> In-Reply-To: <1fc0f5efcc94822f7f5ca9bbcb850faf@gahr.ch> --NQG1e4DpeKdiMcLQlCH5V46sx6sKovkcl Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 3/24/2016 9:24 AM, Pietro Cerutti wrote: > On 2016-03-24 15:54, Matthew Seaman wrote: >> On 2016/03/24 13:29, Sebastian Huber wrote: >>> Hello, >>> >>> is there a ready to use C code formatter available that honours >>> STYLE(9)? I tried clang-format, but it knows only LLVM, Google, >>> Chromium, Mozilla by default. The GNU indent --original seems to prod= uce >>> nothing usable. Same problem with astyle --style=3Dbsd. >>> >> >> pkg uses uncrustify with this config file: >> >> https://github.com/freebsd/pkg/blob/master/freebsd.cfg >> >> It's approximately what style(9) describes but doesn't cover things li= ke >> sorting include files and I don't think it was updated in response to >> the recent change allowing { brackets } around certain single-line >> statements. >=20 > It looks like it does: https://github.com/freebsd/pkg/commit/1bc61a4 >=20 It's not quite right. It is adding {} to single-line if statements in some code. > static __inline struct filemon * > filemon_acquire(struct filemon *filemon) > { > - > - if (filemon !=3D NULL) > + if (filemon !=3D NULL) { > refcount_acquire(&filemon->refcnt); > + } > return (filemon); > } It's also not aware of our (silly?) blank line with no declarations rule:= > static __inline void > filemon_drop(struct filemon *filemon) > { > - > sx_xunlock(&filemon->lock); > filemon_release(filemon); > } And wrapping multiple conditions: > - if (p->p_filemon !=3D NULL && p !=3D curproc) > + if ((p->p_filemon !=3D NULL) && (p !=3D curproc)) { > return (EBUSY); > + } It's also not respecting the wrap rule of tabs + 4 spaces. It's also adding random blank lines before functions and macros. It found a useless 'return;' at least. --=20 Regards, Bryan Drewery --NQG1e4DpeKdiMcLQlCH5V46sx6sKovkcl-- --tQwMehaBEknFFUx9HPnPrg81RIpWiGnGg Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBAgAGBQJW9IMiAAoJEDXXcbtuRpfPU1cH/ixdr8/rNMbe1OdzqRkFbQlw jYbi/LkxEdKE34e4wSEwz4prvOYp19Tv1gFirzuPWQvIBQE0wJW9wrE9InF0t2xQ qZSunrxiTu1+YbdpuJyV59B9YN3khNkyAvEyHV3tJpFOgv1TRaslPJNt9ItozE0j 3m185vII0KUx19VwYfqniFR0iKm98bqbBau1WJ7EjLusqNgN/zz+422Qu/+Snv9T eOIWFocMjAJFqU+HQTQl59HmhtQVk7icd3oWHA6fPX7nb9SUBVhQmF+D2KkFN1Y9 pa+DAeB8njSg4ZYQlasvlnDkuKitnQw+elSatWELCU9LondZkwoF68QGgBLnqIg= =W3pr -----END PGP SIGNATURE----- --tQwMehaBEknFFUx9HPnPrg81RIpWiGnGg--