* [PATCH] Staging: comedi: das16: Fixed a const struct coding style issue
@ 2017-11-26 1:50 Alex Frappier Lachapelle
2017-11-27 10:28 ` Ian Abbott
2017-11-28 2:37 ` kbuild test robot
0 siblings, 2 replies; 6+ messages in thread
From: Alex Frappier Lachapelle @ 2017-11-26 1:50 UTC (permalink / raw)
To: greg; +Cc: abbotti, hsweeten, devel, linux-kernel, Alex Frappier Lachapelle
Fixed a coding style issue.
Signed-off-by: Alex Frappier Lachapelle <Alex.FrappierLachapelle@gmail.com>
---
drivers/staging/comedi/drivers/das16.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c
index ddd4aeab6365..ed1e9e9b651d 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -967,7 +967,7 @@ static const struct comedi_lrange *das16_ai_range(struct comedi_device *dev,
/* get any user-defined input range */
if (pg_type == das16_pg_none && (min || max)) {
- struct comedi_lrange *lrange;
+ const struct comedi_lrange *lrange;
struct comedi_krange *krange;
/* allocate single-range range table */
@@ -1001,7 +1001,7 @@ static const struct comedi_lrange *das16_ao_range(struct comedi_device *dev,
/* get any user-defined output range */
if (min || max) {
- struct comedi_lrange *lrange;
+ const struct comedi_lrange *lrange;
struct comedi_krange *krange;
/* allocate single-range range table */
--
2.15.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] Staging: comedi: das16: Fixed a const struct coding style issue
2017-11-26 1:50 [PATCH] Staging: comedi: das16: Fixed a const struct coding style issue Alex Frappier Lachapelle
@ 2017-11-27 10:28 ` Ian Abbott
2017-11-27 17:51 ` Hartley Sweeten
2017-11-28 2:37 ` kbuild test robot
1 sibling, 1 reply; 6+ messages in thread
From: Ian Abbott @ 2017-11-27 10:28 UTC (permalink / raw)
To: Alex Frappier Lachapelle, greg; +Cc: hsweeten, devel, linux-kernel
On 26/11/17 01:50, Alex Frappier Lachapelle wrote:
> Fixed a coding style issue.
>
> Signed-off-by: Alex Frappier Lachapelle <Alex.FrappierLachapelle@gmail.com>
> ---
> drivers/staging/comedi/drivers/das16.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c
> index ddd4aeab6365..ed1e9e9b651d 100644
> --- a/drivers/staging/comedi/drivers/das16.c
> +++ b/drivers/staging/comedi/drivers/das16.c
> @@ -967,7 +967,7 @@ static const struct comedi_lrange *das16_ai_range(struct comedi_device *dev,
>
> /* get any user-defined input range */
> if (pg_type == das16_pg_none && (min || max)) {
> - struct comedi_lrange *lrange;
> + const struct comedi_lrange *lrange;
> struct comedi_krange *krange;
>
> /* allocate single-range range table */
NAK. The following lines of source code allocate memory pointed to by
'lrange' and modify it, so 'const' is not appropriate here.
> @@ -1001,7 +1001,7 @@ static const struct comedi_lrange *das16_ao_range(struct comedi_device *dev,
>
> /* get any user-defined output range */
> if (min || max) {
> - struct comedi_lrange *lrange;
> + const struct comedi_lrange *lrange;
> struct comedi_krange *krange;
>
> /* allocate single-range range table */
>
Ditto.
--
-=( Ian Abbott @ MEV Ltd. E-mail: <abbotti@mev.co.uk> )=-
-=( Web: http://www.mev.co.uk/ )=-
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH] Staging: comedi: das16: Fixed a const struct coding style issue
2017-11-27 10:28 ` Ian Abbott
@ 2017-11-27 17:51 ` Hartley Sweeten
2017-11-27 22:36 ` Dan Carpenter
2017-11-28 6:59 ` greg
0 siblings, 2 replies; 6+ messages in thread
From: Hartley Sweeten @ 2017-11-27 17:51 UTC (permalink / raw)
To: Ian Abbott, Alex Frappier Lachapelle, greg; +Cc: devel, linux-kernel
On Monday, November 27, 2017 3:28 AM, Ian Abbott wrote:
> On 26/11/17 01:50, Alex Frappier Lachapelle wrote:
>> + const struct comedi_lrange *lrange;
>
> NAK. The following lines of source code allocate memory pointed to by 'lrange' and modify it, so 'const' is not appropriate here.
Ian,
Wonder if it's worth putting a comment about this in the code. This has come up a
couple times.
Regards,
Hartley
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Staging: comedi: das16: Fixed a const struct coding style issue
2017-11-27 17:51 ` Hartley Sweeten
@ 2017-11-27 22:36 ` Dan Carpenter
2017-11-28 6:59 ` greg
1 sibling, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2017-11-27 22:36 UTC (permalink / raw)
To: Hartley Sweeten
Cc: Ian Abbott, Alex Frappier Lachapelle, greg, devel, linux-kernel
On Mon, Nov 27, 2017 at 05:51:56PM +0000, Hartley Sweeten wrote:
> On Monday, November 27, 2017 3:28 AM, Ian Abbott wrote:
> > On 26/11/17 01:50, Alex Frappier Lachapelle wrote:
> >> + const struct comedi_lrange *lrange;
> >
> > NAK. The following lines of source code allocate memory pointed to by 'lrange' and modify it, so 'const' is not appropriate here.
>
> Ian,
>
> Wonder if it's worth putting a comment about this in the code. This has come up a
> couple times.
>
Making it const generates a compile error. A compile error is worth a
thousand comments as they say.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Staging: comedi: das16: Fixed a const struct coding style issue
2017-11-26 1:50 [PATCH] Staging: comedi: das16: Fixed a const struct coding style issue Alex Frappier Lachapelle
2017-11-27 10:28 ` Ian Abbott
@ 2017-11-28 2:37 ` kbuild test robot
1 sibling, 0 replies; 6+ messages in thread
From: kbuild test robot @ 2017-11-28 2:37 UTC (permalink / raw)
To: Alex Frappier Lachapelle
Cc: kbuild-all, greg, abbotti, hsweeten, devel, linux-kernel,
Alex Frappier Lachapelle
[-- Attachment #1: Type: text/plain, Size: 4836 bytes --]
Hi Alex,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on staging/staging-testing]
[also build test ERROR on v4.15-rc1 next-20171127]
[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/Alex-Frappier-Lachapelle/Staging-comedi-das16-Fixed-a-const-struct-coding-style-issue/20171128-090836
config: x86_64-randconfig-x004-201748 (attached as .config)
compiler: gcc-7 (Debian 7.2.0-12) 7.2.1 20171025
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64
All error/warnings (new ones prefixed by >>):
drivers/staging//comedi/drivers/das16.c: In function 'das16_ai_range':
>> drivers/staging//comedi/drivers/das16.c:980:18: error: assignment of member 'length' in read-only object
lrange->length = 1;
^
>> drivers/staging//comedi/drivers/das16.c:981:10: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
krange = lrange->range;
^
drivers/staging//comedi/drivers/das16.c: In function 'das16_ao_range':
drivers/staging//comedi/drivers/das16.c:1014:18: error: assignment of member 'length' in read-only object
lrange->length = 1;
^
drivers/staging//comedi/drivers/das16.c:1015:10: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
krange = lrange->range;
^
vim +/length +980 drivers/staging//comedi/drivers/das16.c
742c4a09 H Hartley Sweeten 2015-01-12 958
0ce8280e H Hartley Sweeten 2015-01-26 959 static const struct comedi_lrange *das16_ai_range(struct comedi_device *dev,
0ce8280e H Hartley Sweeten 2015-01-26 960 struct comedi_subdevice *s,
0ce8280e H Hartley Sweeten 2015-01-26 961 struct comedi_devconfig *it,
0ce8280e H Hartley Sweeten 2015-01-26 962 unsigned int pg_type,
0ce8280e H Hartley Sweeten 2015-01-26 963 unsigned int status)
0ce8280e H Hartley Sweeten 2015-01-26 964 {
0ce8280e H Hartley Sweeten 2015-01-26 965 unsigned int min = it->options[4];
0ce8280e H Hartley Sweeten 2015-01-26 966 unsigned int max = it->options[5];
0ce8280e H Hartley Sweeten 2015-01-26 967
0ce8280e H Hartley Sweeten 2015-01-26 968 /* get any user-defined input range */
0ce8280e H Hartley Sweeten 2015-01-26 969 if (pg_type == das16_pg_none && (min || max)) {
680d002a Alex Frappier Lachapelle 2017-11-25 970 const struct comedi_lrange *lrange;
0ce8280e H Hartley Sweeten 2015-01-26 971 struct comedi_krange *krange;
0ce8280e H Hartley Sweeten 2015-01-26 972
0ce8280e H Hartley Sweeten 2015-01-26 973 /* allocate single-range range table */
0ce8280e H Hartley Sweeten 2015-01-26 974 lrange = comedi_alloc_spriv(s,
0ce8280e H Hartley Sweeten 2015-01-26 975 sizeof(*lrange) + sizeof(*krange));
0ce8280e H Hartley Sweeten 2015-01-26 976 if (!lrange)
0ce8280e H Hartley Sweeten 2015-01-26 977 return &range_unknown;
0ce8280e H Hartley Sweeten 2015-01-26 978
0ce8280e H Hartley Sweeten 2015-01-26 979 /* initialize ai range */
0ce8280e H Hartley Sweeten 2015-01-26 @980 lrange->length = 1;
0ce8280e H Hartley Sweeten 2015-01-26 @981 krange = lrange->range;
0ce8280e H Hartley Sweeten 2015-01-26 982 krange->min = min;
0ce8280e H Hartley Sweeten 2015-01-26 983 krange->max = max;
0ce8280e H Hartley Sweeten 2015-01-26 984 krange->flags = UNIT_volt;
0ce8280e H Hartley Sweeten 2015-01-26 985
0ce8280e H Hartley Sweeten 2015-01-26 986 return lrange;
0ce8280e H Hartley Sweeten 2015-01-26 987 }
0ce8280e H Hartley Sweeten 2015-01-26 988
0ce8280e H Hartley Sweeten 2015-01-26 989 /* use software programmable range */
0ce8280e H Hartley Sweeten 2015-01-26 990 if (status & DAS16_STATUS_UNIPOLAR)
0ce8280e H Hartley Sweeten 2015-01-26 991 return das16_ai_uni_lranges[pg_type];
0ce8280e H Hartley Sweeten 2015-01-26 992 return das16_ai_bip_lranges[pg_type];
0ce8280e H Hartley Sweeten 2015-01-26 993 }
0ce8280e H Hartley Sweeten 2015-01-26 994
:::::: The code at line 980 was first introduced by commit
:::::: 0ce8280e2876091b5c67cb515fae8e9bf3b50bfd staging: comedi: das16: introduce das16_ai_range()
:::::: TO: H Hartley Sweeten <hsweeten@visionengravers.com>
:::::: CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 29066 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Staging: comedi: das16: Fixed a const struct coding style issue
2017-11-27 17:51 ` Hartley Sweeten
2017-11-27 22:36 ` Dan Carpenter
@ 2017-11-28 6:59 ` greg
1 sibling, 0 replies; 6+ messages in thread
From: greg @ 2017-11-28 6:59 UTC (permalink / raw)
To: Hartley Sweeten; +Cc: Ian Abbott, Alex Frappier Lachapelle, devel, linux-kernel
On Mon, Nov 27, 2017 at 05:51:56PM +0000, Hartley Sweeten wrote:
> On Monday, November 27, 2017 3:28 AM, Ian Abbott wrote:
> > On 26/11/17 01:50, Alex Frappier Lachapelle wrote:
> >> + const struct comedi_lrange *lrange;
> >
> > NAK. The following lines of source code allocate memory pointed to by 'lrange' and modify it, so 'const' is not appropriate here.
>
> Ian,
>
> Wonder if it's worth putting a comment about this in the code. This has come up a
> couple times.
It's a nice test to see who actually builds the code before they send a
patch in :)
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-11-28 6:59 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-26 1:50 [PATCH] Staging: comedi: das16: Fixed a const struct coding style issue Alex Frappier Lachapelle
2017-11-27 10:28 ` Ian Abbott
2017-11-27 17:51 ` Hartley Sweeten
2017-11-27 22:36 ` Dan Carpenter
2017-11-28 6:59 ` greg
2017-11-28 2:37 ` kbuild test robot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.