make nidstring.c kernel style compliant
cover make nidstring.c kernel style compliant
Last patch set to make nidstring.c and nidstr.h both report no errors with checkpatch and removal of the remaining white spaces.
James Simmons (3):
staging: lustre: checkpatch cleanups for nidstring.c
staging: lustre: white space cleanups for nidstring.c
staging: lustre: checkpatch cleanups for nidstr.h
drivers/staging/lustre/include/linux/lnet/nidstr.h | 9 ++- drivers/staging/lustre/lnet/lnet/nidstrings.c | 98 +++++++++++--------- 2 files changed, 60 insertions(+), 47 deletions(-)
PATCH 1/3 staging: lustre: checkpatch cleanups for nidstring.c
With nidstring now having the latest fixes we can
now clean up all the remaining checkpatch errors
for nidstring.c.
--- drivers/staging/lustre/lnet/lnet/nidstrings.c | 80 ++++++++++++++----------- 1 files changed, 44 insertions(+), 36 deletions(-)
drivers/staging/lustre/lnet/lnet/nidstrings.c +44 -36
@@ -162,6 +162,7 @@ struct addrrange {static int parse_addrange (const struct cfs_lstr *src,struct nidrange *nidrange) { +struct netstrfns *nf = nidrange->nr_netstrfns;struct addrrange *addrrange;if (src->ls_len ==1 && src->ls_str[0 ] =='*' ) {
@@ -170,14 +171,13 @@ parse_addrange(const struct cfs_lstr *src, struct nidrange *nidrange) }LIBCFS_ALLOC (addrrange,sizeof (struct addrrange )); -if (addrrange ==NULL ) +if (!addrrange)return -ENOMEM ;list_add_tail (&addrrange->ar_link, &nidrange->nr_addrranges);INIT_LIST_HEAD (&addrrange->ar_numaddr_ranges); -return nidrange->nr_netstrfns->nf_parse_addrlist (src->ls_str, - src->ls_len, - &addrrange->ar_numaddr_ranges); +return nf->nf_parse_addrlist (src->ls_str, src->ls_len, + &addrrange->ar_numaddr_ranges); }/**
@@ -203,16 +203,18 @@ add_nidrange(const struct cfs_lstr *src,return NULL ; nf =libcfs_namenum2netstrfns (src->ls_str); -if (nf ==NULL ) +if (!nf)return NULL ; endlen = src->ls_len -strlen (nf->nf_name);if (endlen ==0 )/* network name only, e.g. "elan" or "tcp" */ netnum =0 ;else { -/* e.g. "elan25" or "tcp23", refuse to parse if +/* +* e.g. "elan25" or "tcp23", refuse to parse if * network name is not appended with decimal or -* hexadecimal number */ +* hexadecimal number +*/ if (!cfs_str2num_check (src->ls_str +strlen (nf->nf_name), endlen, &netnum,0 ,MAX_NUMERIC_VALUE ))return NULL ;
@@ -227,7 +229,7 @@ add_nidrange(const struct cfs_lstr *src, }LIBCFS_ALLOC (nr,sizeof (struct nidrange )); -if (nr ==NULL ) +if (!nr)return NULL ;list_add_tail (&nr->nr_link, nidlist);INIT_LIST_HEAD (&nr->nr_addrranges);
@@ -256,11 +258,11 @@ parse_nidrange(struct cfs_lstr *src, struct list_head *nidlist)if (cfs_gettok (src,'@' , &addrrange) ==0 ) goto failed; -if (cfs_gettok (src,'@' , &net) ==0 || src->ls_str !=NULL ) +if (cfs_gettok (src,'@' , &net) ==0 || src->ls_str) goto failed; nr =add_nidrange (&net, nidlist); -if (nr ==NULL ) +if (!nr) goto failed;if (parse_addrange (&addrrange, nr) !=0 )
@@ -370,15 +372,17 @@ int cfs_match_nid(lnet_nid_t nid, struct list_head *nidlist)struct addrrange *ar;list_for_each_entry (nr, nidlist, nr_link) { -if (nr->nr_netstrfns->nf_type !=LNET_NETTYP (LNET_NIDNET (nid))) +struct netstrfns *nf = nr->nr_netstrfns; + +if (nf->nf_type !=LNET_NETTYP (LNET_NIDNET (nid)))continue ;if (nr->nr_netnum !=LNET_NETNUM (LNET_NIDNET (nid)))continue ;if (nr->nr_all)return 1 ;list_for_each_entry (ar, &nr->nr_addrranges, ar_link) -if (nr->nr_netstrfns->nf_match_addr (LNET_NIDADDR (nid), - &ar->ar_numaddr_ranges)) +if (nf->nf_match_addr (LNET_NIDADDR (nid), + &ar->ar_numaddr_ranges))return 1 ; }return 0 ;
@@ -487,13 +491,13 @@ static void cfs_ip_ar_min_max(struct addrrange *ar, __u32 *min_nid, tmp_ip_addr = ((min_ip[0 ] <<24 ) | (min_ip[1 ] <<16 ) | (min_ip[2 ] <<8 ) | min_ip[3 ]); -if (min_nid !=NULL ) +if (min_nid) *min_nid = tmp_ip_addr; tmp_ip_addr = ((max_ip[0 ] <<24 ) | (max_ip[1 ] <<16 ) | (max_ip[2 ] <<8 ) | max_ip[3 ]); -if (max_nid !=NULL ) +if (max_nid) *max_nid = tmp_ip_addr; }
@@ -522,9 +526,9 @@ static void cfs_num_ar_min_max(struct addrrange *ar, __u32 *min_nid, } } -if (min_nid !=NULL ) +if (min_nid) *min_nid = min_addr; -if (max_nid !=NULL ) +if (max_nid) *max_nid = max_addr; }
@@ -546,7 +550,7 @@ bool cfs_nidrange_is_contiguous(struct list_head *nidlist)list_for_each_entry (nr, nidlist, nr_link) { nf = nr->nr_netstrfns; -if (lndname ==NULL ) +if (!lndname) lndname = nf->nf_name;if (netnum ==-1 ) netnum = nr->nr_netnum;
@@ -556,7 +560,7 @@ bool cfs_nidrange_is_contiguous(struct list_head *nidlist)return false; } -if (nf ==NULL ) +if (!nf)return false;if (!nf->nf_is_contiguous (nidlist))
@@ -763,9 +767,9 @@ static void cfs_ip_min_max(struct list_head *nidlist, __u32 *min_nid, } } -if (min_nid !=NULL ) +if (min_nid) *min_nid = min_ip_addr; -if (max_nid !=NULL ) +if (max_nid) *max_nid = max_ip_addr; }
@@ -784,12 +788,14 @@ libcfs_ip_addr2str(__u32 addr, char *str, size_t size) (addr >> 8) & 0xff, addr & 0xff); } -/* CAVEAT EMPTOR XscanfX +/* +* CAVEAT EMPTOR XscanfX * I use "%n" at the end of a sscanf format to detect trailing junk. However * sscanf may return immediately if it sees the terminating '0' in a string, so * I initialise the %n variable to the expected length. If sscanf sets it; * fine, if it doesn't, then the scan ended at the end of the string, which is -* fine too :) */ +* fine too :) +*/ static int libcfs_ip_str2addr (const char *str,int nob,__u32 *addr) {
@@ -804,7 +810,7 @@ libcfs_ip_str2addr(const char *str, int nob, __u32 *addr) n == nob && (a & ~0xff ) ==0 && (b & ~0xff ) ==0 && (c & ~0xff) == 0 && (d & ~0xff) == 0) { - *addr = ((a<<24 )|(b<<16 )|(c<<8 )|d); + *addr = ((a <<24 ) | (b <<16 ) | (c <<8 ) | d);return 1 ; }
@@ -824,7 +830,7 @@ cfs_ip_addr_parse(char *str, int len, struct list_head *list) src.ls_len = len; i =0 ; -while (src.ls_str !=NULL ) { +while (src.ls_str) {struct cfs_lstr res;if (!cfs_gettok (&src,'.' , &res)) {
@@ -1060,7 +1066,9 @@ libcfs_name2netstrfns(const char *name)int libcfs_isknown_lnd (__u32 lnd) { -return libcfs_lnd2netstrfns (lnd) !=NULL ; +struct netstrfns *nf =libcfs_lnd2netstrfns (lnd); + +return nf ?1 :0 ; }EXPORT_SYMBOL (libcfs_isknown_lnd);
@@ -1069,7 +1077,7 @@ libcfs_lnd2modname(__u32 lnd) {struct netstrfns *nf =libcfs_lnd2netstrfns (lnd); -return (nf ==NULL ) ?NULL : nf->nf_modname; +return !nf ?NULL : nf->nf_modname; }EXPORT_SYMBOL (libcfs_lnd2modname);
@@ -1078,7 +1086,7 @@ libcfs_str2lnd(const char *str) {struct netstrfns *nf =libcfs_name2netstrfns (str); -if (nf !=NULL ) +if (nf)return nf->nf_type;return -1 ;
@@ -1091,7 +1099,7 @@ libcfs_lnd2str_r(__u32 lnd, char *buf, size_t buf_size)struct netstrfns *nf; nf =libcfs_lnd2netstrfns (lnd); -if (nf ==NULL ) +if (!nf)snprintf (buf, buf_size,"?%u?" , lnd);else snprintf (buf, buf_size,"%s" , nf->nf_name);
@@ -1108,7 +1116,7 @@ libcfs_net2str_r(__u32 net, char *buf, size_t buf_size)struct netstrfns *nf; nf =libcfs_lnd2netstrfns (lnd); -if (nf ==NULL ) +if (!nf)snprintf (buf, buf_size,"<%u:%u>" , lnd, nnum);else if (nnum ==0 )snprintf (buf, buf_size,"%s" , nf->nf_name);
@@ -1135,9 +1143,9 @@ libcfs_nid2str_r(lnet_nid_t nid, char *buf, size_t buf_size) } nf =libcfs_lnd2netstrfns (lnd); -if (nf ==NULL ) +if (!nf) {snprintf (buf, buf_size,"%x@<%u:%u>" , addr, lnd, nnum); -else { + }else {size_t addr_len; nf->nf_addr2str (addr, buf, buf_size);
@@ -1195,7 +1203,7 @@ libcfs_str2net(const char *str) {__u32 net; -if (libcfs_str2net_internal (str, &net) !=NULL ) +if (libcfs_str2net_internal (str, &net))return net;return LNET_NIDNET (LNET_NID_ANY );
@@ -1210,15 +1218,15 @@ libcfs_str2nid(const char *str)__u32 net;__u32 addr; -if (sep !=NULL ) { +if (sep) { nf =libcfs_str2net_internal (sep +1 , &net); -if (nf ==NULL ) +if (!nf)return LNET_NID_ANY ; }else { sep = str +strlen (str); net =LNET_MKNET (SOCKLND ,0 ); nf =libcfs_lnd2netstrfns (SOCKLND ); -LASSERT (nf !=NULL ); +LASSERT (nf); }if (!nf->nf_str2addr (str, (int )(sep - str), &addr))
Signature · 1 line
1.7.1
Re: [PATCH 1/3] staging: lustre: checkpatch cleanups for nidstring.c
Quoted 6 lines · James Simmons
With nidstring now having the latest fixes we can
now clean up all the remaining checkpatch errors
fornidstring.c.Signed-off-by James Simmons <[email protected]>---
You are doing different types of changes in this patch. Please split them.
regards
sudip
Greg Kroah-Hartman
maintainerRe: [PATCH 1/3] staging: lustre: checkpatch cleanups for nidstring.c
In reply to James SimmonsQuoted 3 lines · James Simmons
With nidstring now having the latest fixes we can
now clean up all the remaining checkpatch errors
fornidstring.c.
Please be specific as to exactly what you changed, and break it up into one-patch-per-thing. And no, "fix all checkpatch errors" is not "one thing"
thanks,
greg k-h
RE: [lustre-devel] [PATCH 1/3] staging: lustre: checkpatch cleanups for nidstring.c
Quoted 8 lines · James Simmons
Quoted 3 lines
With nidstring now having the latest fixes we can
now clean up all the remaining checkpatch errors
fornidstring.c.Please be specific as to exactly what you changed, and break it up into one-patch-per-thing. And no, "fix all checkpatch errors" is not "one thing"
Hmm. This makes me think I might be going about this wrong. Instead of doing style changes per file I should be doing one style change per subsystem instead. Unless you prefer doing these style changes on per file base. Perhaps for now I should focus on pushing the fixes that have cumulated and once caught up then finished off the style issues.
Re: [lustre-devel] [PATCH 1/3] staging: lustre: checkpatch cleanups for nidstring.c
I suspect you're over-thinking it. The maintainers appear to be reacting to the different types of style changes - "checkpatch cleanups" is an awfully broad commit message. I'd suggest breaking this patch (and any others like it) into two pieces; one with whitespace cleanups, and one with the "== NULL" fixes (and mentioning both by kind in the commit message, rather than just attributing to checkpatch). Then issue a v2 of the series, and see where you land.
Of course, YMMV. :-)
--
Mike Shuey
Quoted 18 lines · James A.
Quoted 8 lines · James Simmons
Quoted 3 lines
With nidstring now having the latest fixes we can
now clean up all the remaining checkpatch errors
fornidstring.c.Please be specific as to exactly what you changed, and break it up into one-patch-per-thing. And no, "fix all checkpatch errors" is not "one thing"
Hmm. This makes me think I might be going about this wrong. Instead of doing style changes per file I should be doing one style change per subsystem instead. Unless you prefer doing these style changes on per file base. Perhaps for now I should focus on pushing the fixes that have cumulated and once caught up then finished off the style issues.
_______________________________________________
lustre-devel mailing list
lustre-devel at lists.lustre.org
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
Re: [lustre-devel] [PATCH 1/3] staging: lustre: checkpatch cleanups for nidstring.c
In reply to Simmons, James A.Yeah. That is often the fastest way to fix all the checkpatch warnings.
Checkpatch warnings are pretty mechanical. Just send like 100 patches at a time until everything is fixed. Don't overthink. Say your patch breaks the alignment then you have to fix that, but otherwise only fix one thing at a time. Sometimes people will ask you to fix something else on the same line, but just say "I didn't introduce that, but yes I am planning to fix that in a later patchset since I am following the one thing per patch rule."
Don't feel shame about sending many small patches. We pretty much merge everything.
regards,
dan carpenter
RE: [lustre-devel] [PATCH 1/3] staging: lustre: checkpatch cleanups for nidstring.c
Quoted 10 lines
Yeah. That is often the fastest way to fix all the checkpatch warnings.
Checkpatch warnings are pretty mechanical. Just send like 100 patches at a time until everything is fixed. Don't overthink. Say your patch breaks the alignment then you have to fix that, but otherwise only fix one thing at a time. Sometimes people will ask you to fix something else on the same line, but just say "I didn't introduce that, but yes I am planning to fix that in a later patchset since I am following the one thing per patch rule."
Quoted 2 lines
Don't feel shame about sending many small patches. We pretty much merge everything.
It was the sense of it taking forever with that amount of patches needed with the one file approach. Looking at the back log of fixes its not as bad as I thought for libcfs/LNet. Once those fixes are merged the style cleanups can happen pretty quickly.
PATCH 2/3 staging: lustre: white space cleanups for nidstring.c
In reply to James SimmonsRemove the remaining white spaces in nidstring.c.
--- drivers/staging/lustre/lnet/lnet/nidstrings.c | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-)
drivers/staging/lustre/lnet/lnet/nidstrings.c +9 -9
@@ -799,11 +799,11 @@ libcfs_ip_addr2str(__u32 addr, char *str, size_t size)static int libcfs_ip_str2addr (const char *str,int nob,__u32 *addr) { -unsigned int a; -unsigned int b; -unsigned int c; -unsigned int d; -int n = nob;/* XscanfX */ +unsigned int a; +unsigned int b; +unsigned int c; +unsigned int d; +int n = nob;/* XscanfX */ /* numeric IP? */ if (sscanf(str, "%u.%u.%u.%u%n", &a, &b, &c, &d, &n) >= 4 &&
@@ -902,7 +902,7 @@ libcfs_decnum_addr2str(__u32 addr, char *str, size_t size)static int libcfs_num_str2addr (const char *str,int nob,__u32 *addr) { -int n; +int n; n = nob;if (sscanf (str,"0x%x%n" , addr, &n) >=1 && n == nob)
@@ -931,7 +931,7 @@ static int libcfs_num_parse(char *str, int len, struct list_head *list) {struct cfs_expr_list *el; -int rc; +int rc; rc =cfs_expr_list_parse (str, len,0 ,MAX_NUMERIC_VALUE , &el);if (rc ==0 )
@@ -1054,7 +1054,7 @@ libcfs_namenum2netstrfns(const char *name)static struct netstrfns *libcfs_name2netstrfns (const char *name) { -int i; +int i;for (i =0 ; i < libcfs_nnetstrfns; i++)if (!strcmp (libcfs_netstrfns[i].nf_name, name))
@@ -1201,7 +1201,7 @@ libcfs_str2net_internal(const char *str, __u32 *net)__u32 libcfs_str2net (const char *str) { -__u32 net; +__u32 net;if (libcfs_str2net_internal (str, &net))return net;
Signature · 1 line
1.7.1
PATCH 3/3 staging: lustre: checkpatch cleanups for nidstr.h
In reply to James SimmonsWith nidstr.h now having the latest fixes we can
now clean up all the remaining checkpatch errors
for this header.
--- drivers/staging/lustre/include/linux/lnet/nidstr.h | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-)
drivers/staging/lustre/include/linux/lnet/nidstr.h +7 -2
@@ -34,8 +34,10 @@* Lustre Network Driver types. */ enum { -/* Only add to these values (i.e. don't ever change or redefine them): -* network addresses depend on them... */ +/* +* Only add to these values (i.e. don't ever change or redefine them): +* network addresses depend on them... +*/ QSWLND =1 ,SOCKLND =2 ,GMLND =3 ,
@@ -67,6 +69,7 @@ static inline char *libcfs_lnd2str(__u32 lnd)return libcfs_lnd2str_r (lnd,libcfs_next_nidstring (),LNET_NIDSTR_SIZE ); } +int libcfs_str2lnd (const char *str);char *libcfs_net2str_r (__u32 net,char *buf,size_t buf_size);static inline char *libcfs_net2str (__u32 net)
@@ -74,12 +77,14 @@ static inline char *libcfs_net2str(__u32 net)return libcfs_net2str_r (net,libcfs_next_nidstring (),LNET_NIDSTR_SIZE ); } +char *libcfs_nid2str_r (lnet_nid_t nid,char *buf,size_t buf_size);static inline char *libcfs_nid2str (lnet_nid_t nid) {return libcfs_nid2str_r (nid,libcfs_next_nidstring (),LNET_NIDSTR_SIZE ); } +__u32 libcfs_str2net (const char *str);lnet_nid_t libcfs_str2nid (const char *str);int libcfs_str2anynid (lnet_nid_t *nid,const char *str);
Signature · 1 line
1.7.1