[LTP] [PATCH 2/3] network/stress: add ipsec lib
Alexey Kodanev
alexey.kodanev@oracle.com
Fri Mar 11 12:20:32 CET 2016
Hi,
On 03/11/2016 08:34 AM, Hangbin Liu wrote:
> On Wed, Mar 09, 2016 at 03:42:06PM +0300, Alexey Kodanev wrote:
>>> +# c2x: convert charactor to hex
>>> +c2x()
>>> +{
>>> + for str in $@; do
>>> + for (( i=0; i<${#str}; i++ )); do
>> Not portable "for (());", could be changed to "for i in $(seq 0 ${#str});
>> do.
> Hi Alexey,
>
> Since we need to use the number from 0 to str_len - 1. I think it's also
> not portable if we use like "for i in $(seq 0 $((${#str} - 1))); do". So I
> will keep the format. Please tell me if you have any other suggestion.
No, double parentheses for arithmetic is fine, at least bash, dash and
ash support it.
Also, we could use hexdump, xxd, etc...
c2x()
{
printf "$@" | hexdump -e '/1 "%x"'
}
if $@ contains strings separated by spaces, we could add
"tr -d' '" to it.
Best regards,
Alexey
More information about the ltp
mailing list