net: wireless: fix to uses struct
Subsystems (3)
PATCH 2/2 net: wireless: fix to uses struct
The patch fixed to struct uses in reg.c, I think doesn't need to be use to "struct". There is dataype not have to logical link and each is different definitons.
I'm undecided on this patch. I compiled and didn't to errors.
--- net/wireless/reg.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
net/wireless/reg.c +5 -5
@@ -490,7 +490,7 @@ static int reg_query_builtin(const char *alpha2)if (!regdom)return -ENODATA ; - request =kzalloc (sizeof (struct reg_regdb_apply_request ),GFP_KERNEL ); + request =kzalloc (sizeof (*reg_regdb_apply_request),GFP_KERNEL );if (!request)return -ENOMEM ;
@@ -2291,7 +2291,7 @@ static int regulatory_hint_core(const char *alpha2) {struct regulatory_request *request; - request =kzalloc (sizeof (struct regulatory_request ),GFP_KERNEL ); + request =kzalloc (sizeof (*regulatory_request),GFP_KERNEL );if (!request)return -ENOMEM ;
@@ -2313,7 +2313,7 @@ int regulatory_hint_user(const char *alpha2,if (WARN_ON (!alpha2))return -EINVAL ; - request =kzalloc (sizeof (struct regulatory_request ),GFP_KERNEL ); + request =kzalloc (sizeof (*regulatory_request),GFP_KERNEL );if (!request)return -ENOMEM ;
@@ -2385,7 +2385,7 @@ int regulatory_hint(struct wiphy *wiphy, const char *alpha2) wiphy->regulatory_flags &= ~REGULATORY_CUSTOM_REG ; - request =kzalloc (sizeof (struct regulatory_request ),GFP_KERNEL ); + request =kzalloc (sizeof (*regulatory_request),GFP_KERNEL );if (!request)return -ENOMEM ;
@@ -2661,7 +2661,7 @@ int regulatory_hint_found_beacon(struct wiphy *wiphy,if (processing)return 0 ; - reg_beacon =kzalloc (sizeof (struct reg_beacon ), gfp); + reg_beacon =kzalloc (sizeof (*reg_beacon), gfp);if (!reg_beacon)return -ENOMEM ;
Signature · 1 line
2.1.4
Quoted 1 line · Ozgur Karatas
I compiled and didn't to errors.
Really?
$ make net/wireless/reg.o
CHK include/config/kernel.release
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
CHK include/generated/bounds.h
CHK include/generated/timeconst.h
CHK include/generated/asm-offsets.h
CALL scripts/checksyscalls.sh
CC net/wireless/reg.o
net/wireless/reg.c: In function ‘regulatory_hint_core’:
net/wireless/reg.c:2294:28: error: ‘regulatory_request’ undeclared (first use in this function)
request = kzalloc(sizeof(*regulatory_request), GFP_KERNEL);
^~~~~~~~~~~~~~~~~~
net/wireless/reg.c:2294:28: note: each undeclared identifier is reported only once for each function it appears in
net/wireless/reg.c: In function ‘regulatory_hint_user’:
net/wireless/reg.c:2316:28: error: ‘regulatory_request’ undeclared (first use in this function)
request = kzalloc(sizeof(*regulatory_request), GFP_KERNEL);
^~~~~~~~~~~~~~~~~~
net/wireless/reg.c: In function ‘regulatory_hint’:
net/wireless/reg.c:2388:28: error: ‘regulatory_request’ undeclared (first use in this function)
request = kzalloc(sizeof(*regulatory_request), GFP_KERNEL);
^~~~~~~~~~~~~~~~~~
scripts/Makefile.build:293: recipe for target 'net/wireless/reg.o' failed
make[1]: *** [net/wireless/reg.o] Error 1
Makefile:1640: recipe for target 'net/wireless/reg.o' failed
make: *** [net/wireless/reg.o] Error 2 Didn't Thomas Gleixner suggest that you do a basic C course just yesterday?
Paul Bolle
22.12.2016, 00:34, "Paul Bolle" <[email protected]>:
Quoted 4 lines · Ozgur Karatas
Quoted 1 line
I compiled and didn't to errors.
Really?
I'm very sorry. The "regulatory_request" is defined a static struct. I missed.
line: static struct regulatory_request core_request_world = {
I send to wrong line please can ignore last message and should be fix to as follows:
net/wireless/reg.c +5 -5
@@ -490,7 +490,7 @@ static int reg_query_builtin(const char *alpha2)if (!regdom)return -ENODATA ; - request =kzalloc (sizeof (struct reg_regdb_apply_request ),GFP_KERNEL ); + request =kzalloc (sizeof (*reg_regdb_apply_request),GFP_KERNEL );if (!request)return -ENOMEM ;
@@ -2291,7 +2291,7 @@ static int regulatory_hint_core(const char *alpha2) {struct regulatory_request *request; - request =kzalloc (sizeof (struct regulatory_request ),GFP_KERNEL ); + request =kzalloc (sizeof (*regulatory_request),GFP_KERNEL );if (!request)return -ENOMEM ;
@@ -2313,7 +2313,7 @@ int regulatory_hint_user(const char *alpha2,if (WARN_ON (!alpha2))return -EINVAL ; - request =kzalloc (sizeof (struct regulatory_request ),GFP_KERNEL ); + request =kzalloc (sizeof (*regulatory_request),GFP_KERNEL );if (!request)return -ENOMEM ;
@@ -2385,7 +2385,7 @@ int regulatory_hint(struct wiphy *wiphy, const char *alpha2) wiphy->regulatory_flags &= ~REGULATORY_CUSTOM_REG ; - request =kzalloc (sizeof (struct regulatory_request ),GFP_KERNEL ); + request =kzalloc (sizeof (*regulatory_request),GFP_KERNEL );if (!request)return -ENOMEM ;
@@ -2661,7 +2661,7 @@ int regulatory_hint_found_beacon(struct wiphy *wiphy,if (processing)return 0 ; - reg_beacon =kzalloc (sizeof (struct reg_beacon ), gfp); + reg_beacon =kzalloc (sizeof (*reg_beacon), gfp);if (!reg_beacon)return -ENOMEM ;
Signature · 1 line
2.1.4
Quoted 18 lines
$ make net/wireless/reg.o CHK include/config/kernel.release CHK include/generated/uapi/linux/version.h CHK include/generated/utsrelease.h CHK include/generated/bounds.h CHK include/generated/timeconst.h CHK include/generated/asm-offsets.h CALL scripts/checksyscalls.sh CC net/wireless/reg.o net/wireless/reg.c: In function ‘regulatory_hint_core’: net/wireless/reg.c:2294:28: error: ‘regulatory_request’ undeclared (first use in this function) request = kzalloc(sizeof(*regulatory_request), GFP_KERNEL); ^~~~~~~~~~~~~~~~~~ net/wireless/reg.c:2294:28: note: each undeclared identifier is reported only once for each function it appears in net/wireless/reg.c: In function ‘regulatory_hint_user’: net/wireless/reg.c:2316:28: error: ‘regulatory_request’ undeclared (first use in this function) request = kzalloc(sizeof(*regulatory_request), GFP_KERNEL); ^~~~~~~~~~~~~~~~~~
Quoted 8 lines
net/wireless/reg.c: In function ‘regulatory_hint’: net/wireless/reg.c:2388:28: error: ‘regulatory_request’ undeclared (first use in this function) request = kzalloc(sizeof(*regulatory_request), GFP_KERNEL); ^~~~~~~~~~~~~~~~~~ scripts/Makefile.build:293: recipe for target 'net/wireless/reg.o' failed make[1]: *** [net/wireless/reg.o] Error 1 Makefile:1640: recipe for target 'net/wireless/reg.o' failed make: *** [net/wireless/reg.o] Error 2
$ make M=net/wireless/ CC net/wireless//core.o CC net/wireless//sysfs.o CC net/wireless//radiotap.o CC net/wireless//util.o CC net/wireless//reg.o CC net/wireless//scan.o CC net/wireless//nl80211.o CC net/wireless//mlme.o CC net/wireless//ibss.o CC net/wireless//sme.o CC net/wireless//chan.o CC net/wireless//ethtool.o CC net/wireless//mesh.o CC net/wireless//ap.o CC net/wireless//trace.o CC net/wireless//ocb.o LD net/wireless//cfg80211.o LD net/wireless//built-in.o Building modules, stage 2. MODPOST 0 modules
$ make net/wireless/reg.o scripts/kconfig/conf --silentoldconfig Kconfig * * Restart config... * * * Memory power savings *
Quoted 1 line
Didn't Thomas Gleixner suggest that you do a basic C course just yesterday?
I don't have a problem with C programming, So only I'm learning the kernel. Also, this is a lie if say "I'm expert to C".
I think be re-learned every day. wrong?
Quoted 1 line
Paul Bolle
Regards,
~ Ozgur
My previous patch is invalid, I'm sorry.
The last patc will be fellow because "regulatory_request" is defined as a "static struct".
--- net/wireless/reg.c | 10 +++++----- 2 files changed, 2 insertions(+), 2 deletions(-)
net/wireless/reg.c +2 -2
@@ -490,7 +490,7 @@ static int reg_query_builtin(const char *alpha2)if (!regdom)return -ENODATA ; - request =kzalloc (sizeof (struct reg_regdb_apply_request ),GFP_KERNEL ); + request =kzalloc (sizeof (*reg_regdb_apply_request),GFP_KERNEL );if (!request)return -ENOMEM ;
@@ -2661,7 +2661,7 @@ int regulatory_hint_found_beacon(struct wiphy *wiphy,if (processing)return 0 ; - reg_beacon =kzalloc (sizeof (struct reg_beacon ), gfp); + reg_beacon =kzalloc (sizeof (*reg_beacon), gfp);if (!reg_beacon)return -ENOMEM ;
Signature · 1 line
2.1.4
Quoted 1 line · Ozgur Karatas
I don't have a problem with C programming
I'm sorry, but you do need to learn C, at a basic level, first.
Paul Bolle
22.12.2016, 01:06, "Paul Bolle" <[email protected]>:
Quoted 4 lines · Ozgur Karatas
Quoted 1 line
I don't have a problem with C programming
I'm sorry, but you do need to learn C, at a basic level, first.
Hmm, I don't like to discussion but I'm an assertive on C/C++.
So, I'm not into the Linux kernel, I writing code with C/C++ for many years. I'm having trouble using Linux tools and trying to learn git/diff/format-patch/etc.
Also, I'm reading over 600 e-mails per day and I'm reading to Documentation (kernel). I learn :)
I don't have to problem with C, you can see my early codes and software (github).
I need to get a good sense of the coding style and Documentation.
And thank you.
Regards
Quoted 1 line
Paul Bolle
~Ozgur
kbuild test robot
build botreproduce:
Hi Ozgur,
[auto build test ERROR on mac80211-next/master]
[also build test ERROR on v4.9 next-20161221]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Ozgur-Karatas/net-wireless-fixed-to-checkpatch-errors/20161222-125128 base: https://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next.git master config: i386-randconfig-x006-201651 (attached as .config) compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901 reproduce: # save the attached .config to linux build tree make ARCH=i386
All errors (new ones prefixed by >>):
net/wireless/reg.c: In function 'regulatory_hint_core':
>> net/wireless/reg.c:2294:28: error: 'regulatory_request' undeclared (first use in this function)
request = kzalloc(sizeof(*regulatory_request), GFP_KERNEL);
^~~~~~~~~~~~~~~~~~
net/wireless/reg.c:2294:28: note: each undeclared identifier is reported only once for each function it appears in
net/wireless/reg.c: In function 'regulatory_hint_user':
net/wireless/reg.c:2316:28: error: 'regulatory_request' undeclared (first use in this function)
request = kzalloc(sizeof(*regulatory_request), GFP_KERNEL);
^~~~~~~~~~~~~~~~~~
net/wireless/reg.c: In function 'regulatory_hint':
net/wireless/reg.c:2388:28: error: 'regulatory_request' undeclared (first use in this function)
request = kzalloc(sizeof(*regulatory_request), GFP_KERNEL);
^~~~~~~~~~~~~~~~~~vim +/regulatory_request +2294 net/wireless/reg.c
2288 * and when we restore regulatory settings.
2289 */
2290 static int regulatory_hint_core(const char *alpha2)
2291 {
2292 struct regulatory_request *request;
2293
> 2294 request = kzalloc(sizeof(*regulatory_request), GFP_KERNEL);
2295 if (!request)
2296 return -ENOMEM;
2297
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
kbuild test robot
build botreproduce:
Hi Ozgur,
[auto build test ERROR on mac80211-next/master]
[also build test ERROR on v4.9 next-20161221]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Ozgur-Karatas/net-wireless-fixed-to-checkpatch-errors/20161222-125128 base: https://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next.git master config: i386-allmodconfig (attached as .config) compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901 reproduce: # save the attached .config to linux build tree make ARCH=i386
All errors (new ones prefixed by >>):
net/wireless/reg.c: In function 'reg_query_builtin':
>> net/wireless/reg.c:493:28: error: 'reg_regdb_apply_request' undeclared (first use in this function)
request = kzalloc(sizeof(*reg_regdb_apply_request), GFP_KERNEL);
^~~~~~~~~~~~~~~~~~~~~~~
net/wireless/reg.c:493:28: note: each undeclared identifier is reported only once for each function it appears in
net/wireless/reg.c: In function 'regulatory_hint_core':
net/wireless/reg.c:2294:28: error: 'regulatory_request' undeclared (first use in this function)
request = kzalloc(sizeof(*regulatory_request), GFP_KERNEL);
^~~~~~~~~~~~~~~~~~
net/wireless/reg.c: In function 'regulatory_hint_user':
net/wireless/reg.c:2316:28: error: 'regulatory_request' undeclared (first use in this function)
request = kzalloc(sizeof(*regulatory_request), GFP_KERNEL);
^~~~~~~~~~~~~~~~~~
net/wireless/reg.c: In function 'regulatory_hint':
net/wireless/reg.c:2388:28: error: 'regulatory_request' undeclared (first use in this function)
request = kzalloc(sizeof(*regulatory_request), GFP_KERNEL);
^~~~~~~~~~~~~~~~~~vim +/reg_regdb_apply_request +493 net/wireless/reg.c
487 }
488 }
489
490 if (!regdom)
491 return -ENODATA;
492
> 493 request = kzalloc(sizeof(*reg_regdb_apply_request), GFP_KERNEL);
494 if (!request)
495 return -ENOMEM;
496
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Quoted 5 lines · Ozgur Karatas
The patch fixed to struct uses in
reg.c, I think doesn't need to be use to "struct". There is dataype not have to logical link and each is different definitons.I'm undecided on this patch. I compiled and didn't to errors.
There must be something wrong in the way you build stuff, but still just looking at your patch it is fundamentally wrong, which is what makes people say "do a basic C course". Let me try and explain below.
Quoted 10 lines
Signed-off-by Ozgur Karatas <[email protected]>--- net/wireless/reg.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)net/wireless/reg.c +0
-0
net/wireless/reg.c static int reg_query_builtin(const char *alpha2) · line 493
Quoted 5 lines
net/wireless/reg.c +1
-1@@ -490,7 +490,7 @@ static int reg_query_builtin(const char *alpha2)if (!regdom)return -ENODATA ; - request =kzalloc (sizeof (struct reg_regdb_apply_request ),GFP_KERNEL ); + request =kzalloc (sizeof (*reg_regdb_apply_request),GFP_KERNEL );
Making it more abstract to explain what you are doing:
x = foo(sizeof(T), GFP_KERNEL); where T is "struct Y".
which you change to:
x = foo(sizeof(*Y), GFP_KERNEL);
Y has no meaning for the sizeof operator and the compiler will yell at it being an unknown identifier. In a lot of kernel code you will find:
x = foo(sizeof(*x), GFP_KERNEL);
which is probably the coding style fix you are attempting to make, but miserably fail to do so. There is nothing linux kernel specific about this. It is really fundamental knowledge of the C language. The correct change for this instance is:
- request = kzalloc(sizeof(struct reg_regdb_apply_request), GFP_KERNEL);
+ request = kzalloc(sizeof(*request), GFP_KERNEL);
Hope this helps to come up with a working V2 of this patch.
Regards,
Arend