All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil@xs4all.nl>
To: linux-media@vger.kernel.org
Cc: m.chehab@samsung.com, laurent.pinchart@ideasonboard.com,
	s.nawrocki@samsung.com, ismael.luceno@corp.bluecherry.net,
	pete@sensoray.com, Hans Verkuil <hans.verkuil@cisco.com>
Subject: [REVIEWv2 PATCH 17/34] v4l2-ctrls: return elem_size instead of strlen
Date: Mon, 10 Feb 2014 09:46:42 +0100	[thread overview]
Message-ID: <1392022019-5519-18-git-send-email-hverkuil@xs4all.nl> (raw)
In-Reply-To: <1392022019-5519-1-git-send-email-hverkuil@xs4all.nl>

From: Hans Verkuil <hans.verkuil@cisco.com>

When getting a string and the size given by the application is too
short return the max length the string can have (elem_size) instead
of the string length + 1. That makes more sense.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Reviewed-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
---
 drivers/media/v4l2-core/v4l2-ctrls.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
index b4a9ada..160e4c7 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -1298,7 +1298,7 @@ static int ptr_to_user(struct v4l2_ext_control *c,
 	case V4L2_CTRL_TYPE_STRING:
 		len = strlen(ptr.p_char);
 		if (c->size < len + 1) {
-			c->size = len + 1;
+			c->size = ctrl->elem_size;
 			return -ENOSPC;
 		}
 		return copy_to_user(c->string, ptr.p_char, len + 1) ?
-- 
1.8.5.2


  parent reply	other threads:[~2014-02-10  8:48 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-10  8:46 [REVIEWv2 PATCH 00/34] Add support for complex controls, use in solo/go7007 Hans Verkuil
2014-02-10  8:46 ` [REVIEWv2 PATCH 01/34] v4l2-ctrls: increase internal min/max/step/def to 64 bit Hans Verkuil
2014-02-10  8:46 ` [REVIEWv2 PATCH 02/34] v4l2-ctrls: add unit string Hans Verkuil
2014-02-10  8:46 ` [REVIEWv2 PATCH 03/34] v4l2-ctrls: use pr_info/cont instead of printk Hans Verkuil
2014-02-10  8:46 ` [REVIEWv2 PATCH 04/34] videodev2.h: add initial support for complex controls Hans Verkuil
2014-02-10  8:46 ` [REVIEWv2 PATCH 05/34] videodev2.h: add struct v4l2_query_ext_ctrl and VIDIOC_QUERY_EXT_CTRL Hans Verkuil
2014-02-10  8:46 ` [REVIEWv2 PATCH 06/34] v4l2-ctrls: add support for complex types Hans Verkuil
2014-02-10  8:46 ` [REVIEWv2 PATCH 07/34] v4l2: integrate support for VIDIOC_QUERY_EXT_CTRL Hans Verkuil
2014-02-10  8:46 ` [REVIEWv2 PATCH 08/34] v4l2-ctrls: create type_ops Hans Verkuil
2014-02-12 10:55   ` Ricardo Ribalda Delgado
2014-02-12 11:36     ` Hans Verkuil
2014-02-12 12:03       ` Ricardo Ribalda Delgado
2014-02-12 12:31         ` Hans Verkuil
2014-02-12 13:03           ` Ricardo Ribalda Delgado
2014-02-10  8:46 ` [REVIEWv2 PATCH 09/34] v4l2-ctrls: rewrite copy routines to operate on union v4l2_ctrl_ptr Hans Verkuil
2014-02-10  8:46 ` [REVIEWv2 PATCH 10/34] v4l2-ctrls: compare values only once Hans Verkuil
2014-02-10  8:46 ` [REVIEWv2 PATCH 11/34] v4l2-ctrls: prepare for matrix support: add cols & rows fields Hans Verkuil
2014-02-10  8:46 ` [REVIEWv2 PATCH 12/34] v4l2-ctrls: replace cur by a union v4l2_ctrl_ptr Hans Verkuil
2014-02-10  8:46 ` [REVIEWv2 PATCH 13/34] v4l2-ctrls: use 'new' to access pointer controls Hans Verkuil
2014-02-10  8:46 ` [REVIEWv2 PATCH 14/34] v4l2-ctrls: prepare for matrix support Hans Verkuil
2014-02-10  8:46 ` [REVIEWv2 PATCH 15/34] v4l2-ctrls: type_ops can handle matrix elements Hans Verkuil
2014-02-10  8:46 ` [REVIEWv2 PATCH 16/34] v4l2-ctrls: add matrix support Hans Verkuil
2014-02-10  8:46 ` Hans Verkuil [this message]
2014-02-10  8:46 ` [REVIEWv2 PATCH 18/34] v4l2-ctrl: fix error return of copy_to/from_user Hans Verkuil
2014-02-10  8:46 ` [REVIEWv2 PATCH 19/34] DocBook media: document VIDIOC_QUERY_EXT_CTRL Hans Verkuil
2014-02-10  8:46 ` [REVIEWv2 PATCH 20/34] DocBook media: update VIDIOC_G/S/TRY_EXT_CTRLS Hans Verkuil
2014-02-10  8:46 ` [REVIEWv2 PATCH 21/34] DocBook media: fix coding style in the control example code Hans Verkuil
2014-02-10  8:46 ` [REVIEWv2 PATCH 22/34] DocBook media: update control section Hans Verkuil
2014-02-10  8:46 ` [REVIEWv2 PATCH 23/34] v4l2-controls.txt: update to the new way of accessing controls Hans Verkuil
2014-02-10  8:46 ` [REVIEWv2 PATCH 24/34] v4l2-ctrls/videodev2.h: add u8 and u16 types Hans Verkuil
2014-02-12 10:44   ` Ricardo Ribalda Delgado
2014-02-12 11:20     ` Hans Verkuil
2014-02-12 12:11       ` Ricardo Ribalda Delgado
2014-02-12 12:40         ` Hans Verkuil
2014-02-12 13:13           ` Ricardo Ribalda Delgado
2014-02-12 13:26             ` Hans Verkuil
2014-02-12 13:40               ` Ricardo Ribalda Delgado
2014-02-12 14:05                 ` Hans Verkuil
2014-02-10  8:46 ` [REVIEWv2 PATCH 25/34] DocBook media: document new u8 and u16 control types Hans Verkuil
2014-02-10  8:46 ` [REVIEWv2 PATCH 26/34] v4l2-ctrls: fix comments Hans Verkuil
2014-02-10  8:46 ` [REVIEWv2 PATCH 27/34] v4l2-ctrls/v4l2-controls.h: add MD controls Hans Verkuil
2014-02-10  8:46 ` [REVIEWv2 PATCH 28/34] DocBook media: document new motion detection controls Hans Verkuil
2014-02-10  8:46 ` [REVIEWv2 PATCH 29/34] v4l2: add a motion detection event Hans Verkuil
2014-02-10  8:46 ` [REVIEWv2 PATCH 30/34] DocBook: document new v4l " Hans Verkuil
2014-02-10  8:46 ` [REVIEWv2 PATCH 31/34] solo6x10: implement the new motion detection controls Hans Verkuil
2014-02-10  8:46 ` [REVIEWv2 PATCH 32/34] solo6x10: implement the motion detection event Hans Verkuil
2014-02-10  8:46 ` [REVIEWv2 PATCH 33/34] solo6x10: fix 'dma from stack' warning Hans Verkuil
2014-02-10  8:46 ` [REVIEWv2 PATCH 34/34] go7007: add motion detection support Hans Verkuil
2014-02-12  7:56   ` [REVIEWv2 PATCH 35/34] DocBook media: clarify how the matrix maps to the grid Hans Verkuil
2014-02-12 11:39 ` [REVIEWv2 PATCH 36/34] v4l2-ctrls: break off loop on first changed element Hans Verkuil
2014-02-16 20:14 ` [REVIEWv2 PATCH 00/34] Add support for complex controls, use in solo/go7007 Sakari Ailus
2014-02-17  9:45   ` Hans Verkuil

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=1392022019-5519-18-git-send-email-hverkuil@xs4all.nl \
    --to=hverkuil@xs4all.nl \
    --cc=hans.verkuil@cisco.com \
    --cc=ismael.luceno@corp.bluecherry.net \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=m.chehab@samsung.com \
    --cc=pete@sensoray.com \
    --cc=s.nawrocki@samsung.com \
    /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 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.