From: "Németh Márton" <nm127@freemail.hu>
To: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Cc: V4L Mailing List <linux-media@vger.kernel.org>
Subject: Re: [PATCH] soc_camera: match signedness of soc_camera_limit_side()
Date: Wed, 27 Jan 2010 19:11:32 +0100 [thread overview]
Message-ID: <4B6081D4.5070501@freemail.hu> (raw)
In-Reply-To: <Pine.LNX.4.64.1001271645440.5073@axis700.grange>
[-- Attachment #1: Type: text/plain, Size: 8235 bytes --]
Guennadi Liakhovetski wrote:
> On Sat, 23 Jan 2010, Németh Márton wrote:
>
>> From: Márton Németh <nm127@freemail.hu>
>>
>> The parameters of soc_camera_limit_side() are either a pointer to
>> a structure element from v4l2_rect, or constants. The structure elements
>> of the v4l2_rect are signed (see <linux/videodev2.h>) so do the computations
>> also with signed values.
>>
>> This will remove the following sparse warning (see "make C=1"):
>> * incorrect type in argument 1 (different signedness)
>> expected unsigned int *start
>> got signed int *<noident>
>
> Well, it is interesting, but insufficient. And, unfortunately, I don't
> have a good (and easy) recipe for how to fix this properly.
>
> The problem is, that in soc_camera_limit_side all tests and arithmetics
> are performed with unsigned in mind, now, if you change them to signed,
> think what happens, if some of them are negative. No, I don't know when
> negative members of struct v4l2_rect make sense, having them signed
> doesn't seem a very good idea to me. But they cannot be changed - that's a
> part of the user-space API...
>
> Casting all parameters inside that inline to unsigned would be way too
> ugly. Maybe we could at least keep start_min, length_min, and length_max
> unsigned, and only change start and length to signed, and only cast those
> two inside the function. Then, if you grep through all the drivers,
> there's only one location, where soc_camera_limit_side() is called with
> the latter 3 parameters not constant - two calls in
> sh_mobile_ceu_camera.c. So, to keep sparse happy, you'd have to cast
> there. Ideally, you would also add checks there for negative values...
I'll have a look to see what can be done to handle the negative values properly.
>> Signed-off-by: Márton Németh <nm127@freemail.hu>
>> ---
>> diff -r 2a50a0a1c951 linux/include/media/soc_camera.h
>> --- a/linux/include/media/soc_camera.h Sat Jan 23 00:14:32 2010 -0200
>> +++ b/linux/include/media/soc_camera.h Sat Jan 23 10:09:41 2010 +0100
>> @@ -264,9 +264,8 @@
>> common_flags;
>> }
>>
>> -static inline void soc_camera_limit_side(unsigned int *start,
>> - unsigned int *length, unsigned int start_min,
>> - unsigned int length_min, unsigned int length_max)
>> +static inline void soc_camera_limit_side(int *start, int *length,
>> + int start_min, int length_min, int length_max)
>> {
>> if (*length < length_min)
>> *length = length_min;
>> diff -r 2a50a0a1c951 linux/drivers/media/video/rj54n1cb0c.c
>> --- a/linux/drivers/media/video/rj54n1cb0c.c Sat Jan 23 00:14:32 2010 -0200
>> +++ b/linux/drivers/media/video/rj54n1cb0c.c Sat Jan 23 10:09:41 2010 +0100
>> @@ -555,15 +555,15 @@
>> return ret;
>> }
>>
>> -static int rj54n1_sensor_scale(struct v4l2_subdev *sd, u32 *in_w, u32 *in_h,
>> - u32 *out_w, u32 *out_h);
>> +static int rj54n1_sensor_scale(struct v4l2_subdev *sd, s32 *in_w, s32 *in_h,
>> + s32 *out_w, s32 *out_h);
>>
>> static int rj54n1_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
>> {
>> struct i2c_client *client = sd->priv;
>> struct rj54n1 *rj54n1 = to_rj54n1(client);
>> struct v4l2_rect *rect = &a->c;
>> - unsigned int dummy = 0, output_w, output_h,
>> + int dummy = 0, output_w, output_h,
>> input_w = rect->width, input_h = rect->height;
>> int ret;
>
> And these:
>
> if (output_w > max(512U, input_w / 2)) {
> if (output_h > max(384U, input_h / 2)) {
>
> would now produce compiler warnings... Have you actually tried to compile
> your patch? You'll also have to change formats in dev_dbg() calls here...
Interesting to hear about compiler warnings. I don't get them if I apply the patch
on top of version 14064:31eaa9423f98 of http://linuxtv.org/hg/v4l-dvb/ . What
is your compiler version?
I used the attached configuration. Maybe some other options has to be
turned on?
localhost:/usr/src/linuxtv.org/v4l-dvb$ patch -p1 <../soc_camera_signedness.patch
patching file linux/include/media/soc_camera.h
patching file linux/drivers/media/video/rj54n1cb0c.c
localhost:/usr/src/linuxtv.org/v4l-dvb$ make C=1 2>&1 |tee result1.txt
make -C /usr/src/linuxtv.org/v4l-dvb/v4l
make[1]: Entering directory `/usr/src/linuxtv.org/v4l-dvb/v4l'
creating symbolic links...
make -C firmware prep
make[2]: Entering directory `/usr/src/linuxtv.org/v4l-dvb/v4l/firmware'
make[2]: Leaving directory `/usr/src/linuxtv.org/v4l-dvb/v4l/firmware'
make -C firmware
make[2]: Entering directory `/usr/src/linuxtv.org/v4l-dvb/v4l/firmware'
make[2]: Nothing to be done for `default'.
make[2]: Leaving directory `/usr/src/linuxtv.org/v4l-dvb/v4l/firmware'
Kernel build directory is /lib/modules/2.6.33-rc4/build
make -C /lib/modules/2.6.33-rc4/build SUBDIRS=/usr/src/linuxtv.org/v4l-dvb/v4l modules
make[2]: Entering directory `/usr/src/linuxtv.org/pinchartl/uvcvideo/v4l-dvb'
CHECK /usr/src/linuxtv.org/v4l-dvb/v4l/mt9m001.c
CC [M] /usr/src/linuxtv.org/v4l-dvb/v4l/mt9m001.o
CHECK /usr/src/linuxtv.org/v4l-dvb/v4l/mt9m111.c
CC [M] /usr/src/linuxtv.org/v4l-dvb/v4l/mt9m111.o
CHECK /usr/src/linuxtv.org/v4l-dvb/v4l/mt9t031.c
CC [M] /usr/src/linuxtv.org/v4l-dvb/v4l/mt9t031.o
CHECK /usr/src/linuxtv.org/v4l-dvb/v4l/mt9t112.c
CC [M] /usr/src/linuxtv.org/v4l-dvb/v4l/mt9t112.o
CHECK /usr/src/linuxtv.org/v4l-dvb/v4l/mt9v022.c
CC [M] /usr/src/linuxtv.org/v4l-dvb/v4l/mt9v022.o
CHECK /usr/src/linuxtv.org/v4l-dvb/v4l/ov772x.c
CC [M] /usr/src/linuxtv.org/v4l-dvb/v4l/ov772x.o
CHECK /usr/src/linuxtv.org/v4l-dvb/v4l/ov9640.c
CC [M] /usr/src/linuxtv.org/v4l-dvb/v4l/ov9640.o
CHECK /usr/src/linuxtv.org/v4l-dvb/v4l/rj54n1cb0c.c
CC [M] /usr/src/linuxtv.org/v4l-dvb/v4l/rj54n1cb0c.o
CHECK /usr/src/linuxtv.org/v4l-dvb/v4l/tw9910.c
CC [M] /usr/src/linuxtv.org/v4l-dvb/v4l/tw9910.o
CHECK /usr/src/linuxtv.org/v4l-dvb/v4l/soc_camera.c
CC [M] /usr/src/linuxtv.org/v4l-dvb/v4l/soc_camera.o
CHECK /usr/src/linuxtv.org/v4l-dvb/v4l/soc_camera_platform.c
CC [M] /usr/src/linuxtv.org/v4l-dvb/v4l/soc_camera_platform.o
Building modules, stage 2.
MODPOST 28 modules
LD [M] /usr/src/linuxtv.org/v4l-dvb/v4l/mt9m001.ko
LD [M] /usr/src/linuxtv.org/v4l-dvb/v4l/mt9m111.ko
LD [M] /usr/src/linuxtv.org/v4l-dvb/v4l/mt9t031.ko
LD [M] /usr/src/linuxtv.org/v4l-dvb/v4l/mt9t112.ko
LD [M] /usr/src/linuxtv.org/v4l-dvb/v4l/mt9v022.ko
LD [M] /usr/src/linuxtv.org/v4l-dvb/v4l/ov772x.ko
LD [M] /usr/src/linuxtv.org/v4l-dvb/v4l/ov9640.ko
LD [M] /usr/src/linuxtv.org/v4l-dvb/v4l/rj54n1cb0c.ko
LD [M] /usr/src/linuxtv.org/v4l-dvb/v4l/soc_camera.ko
LD [M] /usr/src/linuxtv.org/v4l-dvb/v4l/soc_camera_platform.ko
LD [M] /usr/src/linuxtv.org/v4l-dvb/v4l/tw9910.ko
make[2]: Leaving directory `/usr/src/linuxtv.org/pinchartl/uvcvideo/v4l-dvb'
./scripts/rmmod.pl check
found 28 modules
make[1]: Leaving directory `/usr/src/linuxtv.org/v4l-dvb/v4l'
nmarci@asus-eeepc:/usr/src/linuxtv.org/v4l-dvb$ gcc --version
gcc (Debian 4.3.4-6) 4.3.4
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>
>> @@ -638,8 +638,8 @@
>> * the output one, updates the window sizes and returns an error or the resize
>> * coefficient on success. Note: we only use the "Fixed Scaling" on this camera.
>> */
>> -static int rj54n1_sensor_scale(struct v4l2_subdev *sd, u32 *in_w, u32 *in_h,
>> - u32 *out_w, u32 *out_h)
>> +static int rj54n1_sensor_scale(struct v4l2_subdev *sd, s32 *in_w, s32 *in_h,
>> + s32 *out_w, s32 *out_h)
>> {
>> struct i2c_client *client = sd->priv;
>> struct rj54n1 *rj54n1 = to_rj54n1(client);
>> @@ -1017,7 +1017,7 @@
>> struct i2c_client *client = sd->priv;
>> struct rj54n1 *rj54n1 = to_rj54n1(client);
>> const struct rj54n1_datafmt *fmt;
>> - unsigned int output_w, output_h, max_w, max_h,
>> + int output_w, output_h, max_w, max_h,
>> input_w = rj54n1->rect.width, input_h = rj54n1->rect.height;
>> int ret;
>
> and here.
>
> Thanks
> Guennadi
> ---
> Guennadi Liakhovetski, Ph.D.
> Freelance Open-Source Software Developer
> http://www.open-technology.de/
>
>
Regards,
Márton Németh
[-- Attachment #2: .config --]
[-- Type: text/plain, Size: 4716 bytes --]
#
# Automatically generated make config: don't edit
# Linux kernel version: KERNELVERSION
# Wed Jan 27 18:58:24 2010
#
# CONFIG_SND_MIRO is not set
CONFIG_INPUT=y
CONFIG_USB=m
CONFIG_FW_LOADER=y
# CONFIG_SPARC64 is not set
# CONFIG_PLAT_M32700UT is not set
# CONFIG_SND_FM801 is not set
CONFIG_FB_CFB_IMAGEBLIT=y
# CONFIG_GPIO_PCA953X is not set
# CONFIG_HAVE_CLK is not set
# CONFIG_FIQ is not set
CONFIG_SND=m
# CONFIG_MT9M001_PCA9536_SWITCH is not set
# CONFIG_ARCH_OMAP2 is not set
# CONFIG_SPARC32 is not set
CONFIG_I2C_ALGOBIT=m
# CONFIG_SND_ISA is not set
CONFIG_INET=y
CONFIG_CRC32=y
CONFIG_SYSFS=y
CONFIG_MMC=m
CONFIG_ISA=y
CONFIG_PCI=y
CONFIG_PARPORT_1284=y
CONFIG_FB_CFB_FILLRECT=y
# CONFIG_MT9V022_PCA9536_SWITCH is not set
CONFIG_VIRT_TO_BUS=y
CONFIG_PARPORT=m
# CONFIG_ARCH_DAVINCI_DM644x is not set
# CONFIG_FIREWIRE is not set
CONFIG_NET=y
# CONFIG_ARCH_DAVINCI is not set
CONFIG_FB_CFB_COPYAREA=y
# CONFIG_PXA27x is not set
# CONFIG_SGI_IP22 is not set
CONFIG_I2C=m
# CONFIG_ARCH_DAVINCI_DM355 is not set
CONFIG_MODULES=y
# CONFIG_TUNER_XC2028 is not set
CONFIG_HAS_IOMEM=y
# CONFIG_MACH_DAVINCI_DM6467_EVM is not set
CONFIG_HAS_DMA=y
CONFIG_FB=y
# CONFIG_ARCH_MX1 is not set
# CONFIG_SONY_LAPTOP is not set
# CONFIG_MX3_IPU is not set
CONFIG_SND_PCM=m
CONFIG_EXPERIMENTAL=y
# CONFIG_M32R is not set
# CONFIG_IEEE1394 is not set
# CONFIG_VIDEO_KERNEL_VERSION is not set
CONFIG_MEDIA_SUPPORT=m
#
# Multimedia core support
#
CONFIG_VIDEO_DEV=m
CONFIG_VIDEO_V4L2_COMMON=m
# CONFIG_VIDEO_ALLOW_V4L1 is not set
# CONFIG_VIDEO_V4L1_COMPAT is not set
# CONFIG_DVB_CORE is not set
CONFIG_VIDEO_MEDIA=m
#
# Multimedia drivers
#
CONFIG_IR_CORE=m
CONFIG_VIDEO_IR=m
# CONFIG_MEDIA_ATTACH is not set
CONFIG_MEDIA_TUNER=m
# CONFIG_MEDIA_TUNER_CUSTOMISE is not set
CONFIG_MEDIA_TUNER_SIMPLE=m
CONFIG_MEDIA_TUNER_TDA8290=m
CONFIG_MEDIA_TUNER_TDA9887=m
CONFIG_MEDIA_TUNER_TEA5761=m
CONFIG_MEDIA_TUNER_TEA5767=m
CONFIG_MEDIA_TUNER_MT20XX=m
CONFIG_MEDIA_TUNER_XC2028=m
CONFIG_MEDIA_TUNER_XC5000=m
CONFIG_MEDIA_TUNER_MC44S803=m
CONFIG_VIDEO_V4L2=m
CONFIG_VIDEOBUF_GEN=m
CONFIG_VIDEO_CAPTURE_DRIVERS=y
# CONFIG_VIDEO_ADV_DEBUG is not set
# CONFIG_VIDEO_FIXED_MINOR_RANGES is not set
# CONFIG_VIDEO_HELPER_CHIPS_AUTO is not set
# CONFIG_VIDEO_IR_I2C is not set
#
# Encoders/decoders and other helper chips
#
#
# Audio decoders
#
# CONFIG_VIDEO_TVAUDIO is not set
# CONFIG_VIDEO_TDA7432 is not set
# CONFIG_VIDEO_TDA9840 is not set
# CONFIG_VIDEO_TDA9875 is not set
# CONFIG_VIDEO_TEA6415C is not set
# CONFIG_VIDEO_TEA6420 is not set
# CONFIG_VIDEO_MSP3400 is not set
# CONFIG_VIDEO_CS5345 is not set
# CONFIG_VIDEO_CS53L32A is not set
# CONFIG_VIDEO_M52790 is not set
# CONFIG_VIDEO_TLV320AIC23B is not set
# CONFIG_VIDEO_WM8775 is not set
# CONFIG_VIDEO_WM8739 is not set
# CONFIG_VIDEO_VP27SMPX is not set
#
# RDS decoders
#
# CONFIG_VIDEO_SAA6588 is not set
#
# Video decoders
#
# CONFIG_VIDEO_ADV7180 is not set
# CONFIG_VIDEO_BT819 is not set
# CONFIG_VIDEO_BT856 is not set
# CONFIG_VIDEO_BT866 is not set
# CONFIG_VIDEO_KS0127 is not set
# CONFIG_VIDEO_OV7670 is not set
# CONFIG_VIDEO_MT9V011 is not set
# CONFIG_VIDEO_TCM825X is not set
# CONFIG_VIDEO_SAA7110 is not set
# CONFIG_VIDEO_SAA711X is not set
# CONFIG_VIDEO_SAA717X is not set
# CONFIG_VIDEO_TVP514X is not set
# CONFIG_VIDEO_TVP5150 is not set
# CONFIG_VIDEO_VPX3220 is not set
#
# Video and audio decoders
#
# CONFIG_VIDEO_CX25840 is not set
#
# MPEG video encoders
#
# CONFIG_VIDEO_CX2341X is not set
#
# Video encoders
#
# CONFIG_VIDEO_SAA7127 is not set
# CONFIG_VIDEO_SAA7185 is not set
# CONFIG_VIDEO_ADV7170 is not set
# CONFIG_VIDEO_ADV7175 is not set
# CONFIG_VIDEO_THS7303 is not set
# CONFIG_VIDEO_ADV7343 is not set
#
# Video improvement chips
#
# CONFIG_VIDEO_UPD64031A is not set
# CONFIG_VIDEO_UPD64083 is not set
# CONFIG_VIDEO_VIVI is not set
# CONFIG_VIDEO_BT848 is not set
# CONFIG_VIDEO_PMS is not set
# CONFIG_VIDEO_SAA5246A is not set
# CONFIG_VIDEO_SAA5249 is not set
# CONFIG_VIDEO_ZORAN is not set
# CONFIG_VIDEO_SAA7134 is not set
# CONFIG_VIDEO_HEXIUM_ORION is not set
# CONFIG_VIDEO_HEXIUM_GEMINI is not set
# CONFIG_VIDEO_CX88 is not set
# CONFIG_VIDEO_IVTV is not set
# CONFIG_VIDEO_CAFE_CCIC is not set
CONFIG_SOC_CAMERA=m
CONFIG_SOC_CAMERA_MT9M001=m
CONFIG_SOC_CAMERA_MT9M111=m
CONFIG_SOC_CAMERA_MT9T031=m
CONFIG_SOC_CAMERA_MT9T112=m
CONFIG_SOC_CAMERA_MT9V022=m
CONFIG_SOC_CAMERA_RJ54N1=m
CONFIG_SOC_CAMERA_TW9910=m
CONFIG_SOC_CAMERA_PLATFORM=m
CONFIG_SOC_CAMERA_OV772X=m
CONFIG_SOC_CAMERA_OV9640=m
# CONFIG_V4L_USB_DRIVERS is not set
# CONFIG_RADIO_ADAPTERS is not set
# CONFIG_DAB is not set
#
# Audio devices for multimedia
#
#
# ALSA sound
#
# CONFIG_SND_BT87X is not set
# CONFIG_STAGING is not set
next prev parent reply other threads:[~2010-01-27 18:11 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-23 13:43 [PATCH] soc_camera: match signedness of soc_camera_limit_side() Németh Márton
2010-01-27 16:05 ` Guennadi Liakhovetski
2010-01-27 18:11 ` Németh Márton [this message]
2010-01-27 18:22 ` Guennadi Liakhovetski
2010-01-27 19:58 ` Németh Márton
2010-01-27 20:12 ` Guennadi Liakhovetski
2010-01-27 21:42 ` Németh Márton
2010-01-28 20:52 ` Guennadi Liakhovetski
2010-01-28 21:30 ` Németh Márton
2010-02-09 9:05 ` Guennadi Liakhovetski
2010-02-12 9:32 ` Guennadi Liakhovetski
2010-02-24 6:32 ` Németh Márton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4B6081D4.5070501@freemail.hu \
--to=nm127@freemail.hu \
--cc=g.liakhovetski@gmx.de \
--cc=linux-media@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox