Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'net-sched-actions-code-style-cleanup-and-fixes'

Roman Mashak says:

====================
net sched actions: code style cleanup and fixes

The patchset fixes a few code stylistic issues and typos, as well as one
detected by sparse semantic checker tool.

No functional changes introduced.

Patch 1 & 2 fix coding style bits caught by the checkpatch.pl script
Patch 3 fixes an issue with a shadowed variable
Patch 4 adds sizeof() operator instead of magic number for buffer length
Patch 5 fixes typos in diagnostics messages
Patch 6 explicitly sets unsigned char for bitwise operation

v2:
- submit for net-next
- added Reviewed-by tags
- use u8* instead of char* as per Davide Caratti suggestion
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+31 -22
+1
include/net/tc_act/tc_pedit.h
··· 17 17 struct tc_pedit_key *tcfp_keys; 18 18 struct tcf_pedit_key_ex *tcfp_keys_ex; 19 19 }; 20 + 20 21 #define to_pedit(a) ((struct tcf_pedit *)a) 21 22 22 23 static inline bool is_tcf_pedit(const struct tc_action *a)
+7 -2
include/uapi/linux/tc_act/tc_pedit.h
··· 17 17 TCA_PEDIT_KEY_EX, 18 18 __TCA_PEDIT_MAX 19 19 }; 20 + 20 21 #define TCA_PEDIT_MAX (__TCA_PEDIT_MAX - 1) 21 - 22 + 22 23 enum { 23 24 TCA_PEDIT_KEY_EX_HTYPE = 1, 24 25 TCA_PEDIT_KEY_EX_CMD = 2, 25 26 __TCA_PEDIT_KEY_EX_MAX 26 27 }; 28 + 27 29 #define TCA_PEDIT_KEY_EX_MAX (__TCA_PEDIT_KEY_EX_MAX - 1) 28 30 29 31 /* TCA_PEDIT_KEY_EX_HDR_TYPE_NETWROK is a special case for legacy users. It ··· 40 38 TCA_PEDIT_KEY_EX_HDR_TYPE_UDP = 5, 41 39 __PEDIT_HDR_TYPE_MAX, 42 40 }; 41 + 43 42 #define TCA_PEDIT_HDR_TYPE_MAX (__PEDIT_HDR_TYPE_MAX - 1) 44 43 45 44 enum pedit_cmd { ··· 48 45 TCA_PEDIT_KEY_EX_CMD_ADD = 1, 49 46 __PEDIT_CMD_MAX, 50 47 }; 48 + 51 49 #define TCA_PEDIT_CMD_MAX (__PEDIT_CMD_MAX - 1) 52 50 53 51 struct tc_pedit_key { ··· 59 55 __u32 offmask; 60 56 __u32 shift; 61 57 }; 62 - 58 + 63 59 struct tc_pedit_sel { 64 60 tc_gen; 65 61 unsigned char nkeys; 66 62 unsigned char flags; 67 63 struct tc_pedit_key keys[0]; 68 64 }; 65 + 69 66 #define tc_pedit tc_pedit_sel 70 67 71 68 #endif
+23 -20
net/sched/act_pedit.c
··· 136 136 { 137 137 struct tc_action_net *tn = net_generic(net, pedit_net_id); 138 138 struct nlattr *tb[TCA_PEDIT_MAX + 1]; 139 - struct nlattr *pattr; 140 - struct tc_pedit *parm; 141 - int ret = 0, err; 142 - struct tcf_pedit *p; 143 139 struct tc_pedit_key *keys = NULL; 144 140 struct tcf_pedit_key_ex *keys_ex; 141 + struct tc_pedit *parm; 142 + struct nlattr *pattr; 143 + struct tcf_pedit *p; 144 + int ret = 0, err; 145 145 int ksize; 146 146 147 - if (nla == NULL) 147 + if (!nla) 148 148 return -EINVAL; 149 149 150 150 err = nla_parse_nested(tb, TCA_PEDIT_MAX, nla, pedit_policy, NULL); ··· 175 175 return ret; 176 176 p = to_pedit(*a); 177 177 keys = kmalloc(ksize, GFP_KERNEL); 178 - if (keys == NULL) { 178 + if (!keys) { 179 179 tcf_idr_release(*a, bind); 180 180 kfree(keys_ex); 181 181 return -ENOMEM; ··· 220 220 { 221 221 struct tcf_pedit *p = to_pedit(a); 222 222 struct tc_pedit_key *keys = p->tcfp_keys; 223 + 223 224 kfree(keys); 224 225 kfree(p->tcfp_keys_ex); 225 226 } ··· 285 284 if (p->tcfp_nkeys > 0) { 286 285 struct tc_pedit_key *tkey = p->tcfp_keys; 287 286 struct tcf_pedit_key_ex *tkey_ex = p->tcfp_keys_ex; 288 - enum pedit_header_type htype = TCA_PEDIT_KEY_EX_HDR_TYPE_NETWORK; 287 + enum pedit_header_type htype = 288 + TCA_PEDIT_KEY_EX_HDR_TYPE_NETWORK; 289 289 enum pedit_cmd cmd = TCA_PEDIT_KEY_EX_CMD_SET; 290 290 291 291 for (i = p->tcfp_nkeys; i > 0; i--, tkey++) { 292 - u32 *ptr, _data; 292 + u32 *ptr, hdata; 293 293 int offset = tkey->off; 294 294 int hoffset; 295 295 u32 val; ··· 305 303 306 304 rc = pedit_skb_hdr_offset(skb, htype, &hoffset); 307 305 if (rc) { 308 - pr_info("tc filter pedit bad header type specified (0x%x)\n", 306 + pr_info("tc action pedit bad header type specified (0x%x)\n", 309 307 htype); 310 308 goto bad; 311 309 } 312 310 313 311 if (tkey->offmask) { 314 - char *d, _d; 312 + u8 *d, _d; 315 313 316 314 if (!offset_valid(skb, hoffset + tkey->at)) { 317 - pr_info("tc filter pedit 'at' offset %d out of bounds\n", 315 + pr_info("tc action pedit 'at' offset %d out of bounds\n", 318 316 hoffset + tkey->at); 319 317 goto bad; 320 318 } 321 - d = skb_header_pointer(skb, hoffset + tkey->at, 1, 322 - &_d); 319 + d = skb_header_pointer(skb, hoffset + tkey->at, 320 + sizeof(_d), &_d); 323 321 if (!d) 324 322 goto bad; 325 323 offset += (*d & tkey->offmask) >> tkey->shift; 326 324 } 327 325 328 326 if (offset % 4) { 329 - pr_info("tc filter pedit" 330 - " offset must be on 32 bit boundaries\n"); 327 + pr_info("tc action pedit offset must be on 32 bit boundaries\n"); 331 328 goto bad; 332 329 } 333 330 334 331 if (!offset_valid(skb, hoffset + offset)) { 335 - pr_info("tc filter pedit offset %d out of bounds\n", 332 + pr_info("tc action pedit offset %d out of bounds\n", 336 333 hoffset + offset); 337 334 goto bad; 338 335 } 339 336 340 - ptr = skb_header_pointer(skb, hoffset + offset, 4, &_data); 337 + ptr = skb_header_pointer(skb, hoffset + offset, 338 + sizeof(hdata), &hdata); 341 339 if (!ptr) 342 340 goto bad; 343 341 /* just do it, baby */ ··· 349 347 val = (*ptr + tkey->val) & ~tkey->mask; 350 348 break; 351 349 default: 352 - pr_info("tc filter pedit bad command (%d)\n", 350 + pr_info("tc action pedit bad command (%d)\n", 353 351 cmd); 354 352 goto bad; 355 353 } 356 354 357 355 *ptr = ((*ptr & tkey->mask) ^ val); 358 - if (ptr == &_data) 356 + if (ptr == &hdata) 359 357 skb_store_bits(skb, hoffset + offset, ptr, 4); 360 358 } 361 359 362 360 goto done; 363 - } else 361 + } else { 364 362 WARN(1, "pedit BUG: index %d\n", p->tcf_index); 363 + } 365 364 366 365 bad: 367 366 p->tcf_qstats.overlimits++;