Hi Hui, 

Yup, that’s a ‘known’ unformat trap. When unformatting integers, use u32. 

Florin

> On Sep 19, 2017, at 8:33 PM, <[email protected]> <[email protected]> 
> wrote:
> 
> hi all:
> 
> we found some common using issues about the use of CLI unformat, as follow:
> 
> 
> 
> u16 out_port = 0;
> 
> u32 vrf_id = 0, protocol;
> 
> else if (unformat (line_input, "%U %u", unformat_ip4_address,
> 
>                        &out_addr, &out_port))
> 
> 
> 
> when inputing u16 or u8 type param(not u32), the  local variable which behind 
> of "out_port" in stack will be overwrited, is that right? is there some Notes 
> about this?
> 
> I think the bellow code maybe  cause that issue.
> 
> unformat->va_unformat->do_percent->unformat_integer-> *(u32 *) v = value;
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 王辉 wanghui
> 
> 
> 
> IT开发工程师 IT Development Engineer
> 虚拟化南京四部/无线研究院/无线产品经营部 NIV Nanjing Dept. IV/Wireless Product R&D 
> Institute/Wireless Product Operation Division
> 
> 
> 
> 
> _______________________________________________
> vpp-dev mailing list
> [email protected]
> https://lists.fd.io/mailman/listinfo/vpp-dev

_______________________________________________
vpp-dev mailing list
[email protected]
https://lists.fd.io/mailman/listinfo/vpp-dev

Reply via email to