Message ID | 1503633771-112384-2-git-send-email-yi.y.yang@intel.com |
---|---|
State | Accepted |
Headers | show |
> static inline uint16_t > nsh_hdr_len(const struct nsh_hdr *nsh) > { > - return 4 * (ntohs(nsh->ver_flags_len) & NSH_LEN_MASK) >> > NSH_LEN_SHIFT; > + return ((ntohs(nsh->ver_flags_len) & NSH_LEN_MASK) >> > + NSH_LEN_SHIFT) << 2; > } > Why do you not just add the missing braces? return 4 * ((ntohs(nsh->ver_flags_len) & NSH_LEN_MASK) >> NSH_LEN_SHIFT); BR, Jan
On Fri, Aug 25, 2017 at 12:02:49PM +0800, Yi Yang wrote: > Operator '*' will be executed prior to operator '>>', > but we expect operator '>>' is executed prior to '*', > this patch fixed the issue. > > Signed-off-by: Yi Yang <yi.y.yang@intel.com> Applied to master and branch-2.8, thanks!
diff --git a/include/openvswitch/nsh.h b/include/openvswitch/nsh.h index f4ccadc..a3611d0 100644 --- a/include/openvswitch/nsh.h +++ b/include/openvswitch/nsh.h @@ -113,7 +113,7 @@ struct nsh_hdr { static inline uint16_t nsh_hdr_len(const struct nsh_hdr *nsh) { - return 4 * (ntohs(nsh->ver_flags_len) & NSH_LEN_MASK) >> NSH_LEN_SHIFT; + return ((ntohs(nsh->ver_flags_len) & NSH_LEN_MASK) >> NSH_LEN_SHIFT) << 2; } static inline struct nsh_md1_ctx *
Operator '*' will be executed prior to operator '>>', but we expect operator '>>' is executed prior to '*', this patch fixed the issue. Signed-off-by: Yi Yang <yi.y.yang@intel.com> --- include/openvswitch/nsh.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)