[Dnsmasq-discuss] space two point eighty one, take 2
Geert Stappers
stappers at stappers.nl
Sun Mar 8 11:33:32 GMT 2020
On Sat, Mar 07, 2020 at 10:01:30PM +0100, Geert Stappers wrote:
> In-Reply-To: <1255b7ff-351f-46d7-f811-ac3373102662 at thekelleys.org.uk>
> On Thu, Mar 05, 2020 at 10:34:29PM +0000, Simon Kelley wrote:
> > On 05/03/2020 21:05, Geert Stappers wrote:
> > > On Thu, Mar 05, 2020 at 09:46:21PM +0100, Geert Stappers wrote:
> > >>
> > >> I plea for removal of unneeded ' ' and ' '.
> > >>
> > >> That removal can be done with:
> > >> ... remove trailing white_space_only_lines ...
> > >>
> > >> ... empty lines: sed --in-place -e 's/^[ \t]*$//' src/*.c ...
> > >
> > > I love to see that in the 2.81 release of dnsmasq.
> > >
> >
> > The obvious problem with doing that is that for ever more, when I run
> } "git blame" N lines will have the source "Removed useless whitespace".
>
> That valid point shouldn't be a big issue.
> At least I think it can be mitigated.
>
> Now spliting previous change request into two parts:
> * Removing trailing white_space_only_lines
Done, see http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/2020q1/013866.html
Removed lines don't show up in `git blame`.
> * Emptying the empty lines
Execute:
sed --in-place -e 's/^[ \t]*$//' src/*.c src/*.h
<screenshot with="some counting and calculation">
$ git diff | wc
21923 78016 607091
$ git diff | grep ^+ | grep -c -v ^+++
3053
$ wc -l src/*.c src/*.h | tail -n 1
39474 totaal
$ echo "3053 / 39474 * 100" | bc -l
7.73420479302832244000
</screenshot>
To prevent that 8% of the lines in future `git blame`
will distract us by reminding us on this clean-up.
Execute:
git commit -am "Removed useless white space" --author="Simon Kelley <simon at thekelleys.org.uk>"
<sample>
$ git blame src/arp.c | sed --silent -e 60,80p
cc921df9 (Simon Kelley 2019-01-02 22:48:59 +0000 60) if (!IN6_ARE_ADDR_EQUAL(&arp->addr.addr6, (struct in6_addr *)addrp))
11867dc2 (Simon Kelley 2015-12-23 16:15:58 +0000 61) continue;
11867dc2 (Simon Kelley 2015-12-23 16:15:58 +0000 62) }
11867dc2 (Simon Kelley 2015-12-23 16:15:58 +0000 63)
33702ab1 (Simon Kelley 2015-12-28 23:17:15 +0000 64) if (arp->status == ARP_EMPTY)
11867dc2 (Simon Kelley 2015-12-23 16:15:58 +0000 65) {
33702ab1 (Simon Kelley 2015-12-28 23:17:15 +0000 66) /* existing address, was negative. */
11867dc2 (Simon Kelley 2015-12-23 16:15:58 +0000 67) arp->status = ARP_NEW;
11867dc2 (Simon Kelley 2015-12-23 16:15:58 +0000 68) arp->hwlen = maclen;
11867dc2 (Simon Kelley 2015-12-23 16:15:58 +0000 69) memcpy(arp->hwaddr, mac, maclen);
11867dc2 (Simon Kelley 2015-12-23 16:15:58 +0000 70) }
33702ab1 (Simon Kelley 2015-12-28 23:17:15 +0000 71) else if (arp->hwlen == maclen && memcmp(arp->hwaddr, mac, maclen) == 0)
33702ab1 (Simon Kelley 2015-12-28 23:17:15 +0000 72) /* Existing entry matches - confirm. */
33702ab1 (Simon Kelley 2015-12-28 23:17:15 +0000 73) arp->status = ARP_FOUND;
33702ab1 (Simon Kelley 2015-12-28 23:17:15 +0000 74) else
33702ab1 (Simon Kelley 2015-12-28 23:17:15 +0000 75) continue;
ced2a733 (Simon Kelley 2020-03-08 12:17:53 +0100 76)
11867dc2 (Simon Kelley 2015-12-23 16:15:58 +0000 77) break;
11867dc2 (Simon Kelley 2015-12-23 16:15:58 +0000 78) }
11867dc2 (Simon Kelley 2015-12-23 16:15:58 +0000 79)
11867dc2 (Simon Kelley 2015-12-23 16:15:58 +0000 80) if (!arp)
</sample>
Regards
Geert Stappers
--
Silence is hard to parse
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/attachments/20200308/5b2adc0f/attachment.sig>
More information about the Dnsmasq-discuss
mailing list