|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v6] acpi: Prevent GPL-only code from seeping into non-GPL binaries
Boris Ostrovsky writes ("Re: [PATCH v6] acpi: Prevent GPL-only code from
seeping into non-GPL binaries"):
> On 09/26/2016 10:45 AM, Ian Jackson wrote:
> > If the indices are necessarily successive integers:
> >
> > links="A B C D"
> > index=0
> > for link in $links; do
> > index=$(( $index + 1 ))
> > something with $link and $index
> >
> > If the indices are arbitrary:
> >
> > links="1:A 4:B 7:C 10:D"
> > for linkinfo in $links; do
> > link=${linkinfo#*:}
> > index=${linkinfo%%:*}
> > something with $link and $index
>
>
> The indices are not successive, in one case they are a function of two
> enclosing loop indices, such as
By `indices' I meant the things which in your code are 1 2 3 4.
Apparently there is a different thing called an `idx'.
Your code below suggests that the numbers you need for each A B C D
are indeed successive integers.
> for dev in $(seq 1 31)
> do
> for intx in $(seq 0 3)
> do
> link_idx=$(((dev + intx) & 3))
> printf " Package(){0x%04xffff, %u, \\\\_SB.PCI0.LNK%c,
> 0},\n" \
> $dev $intx ${links:$link_idx:1}
> done
> done
>
> (And then there might also be a question of portability with the second
> approach?)
>
> So if you don't object to
>
> link=`echo "A B C D" | cut -d" " -f $i`
>
> I'd rather go with that.
I would still prefer
links="A B C D"
linkcounter=0
for link in $links
do
linkcounter=$(( $linkcounter + 1))
link_idx=$(( ($dev + $linkcounter) & 3 ))
I think this is a lot easier to read than messing about with seq and
string slicing.
NB that the spaces inside the $(( )) are IMO essential for
readability.
Ian.
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |