aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2013-03-18 10:02:22 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-03-24 06:13:54 -0400
commit27d5a87cf4b44cbcbd0f4706a433e4a68d496236 (patch)
tree69513738be875b45d779e8ba1a512def12560352
parent314527acbbb3f33f72c2ef19d8cfabcada9912a5 (diff)
[media] v4l2-ioctl: add precision when printing names
Never print more than the size of the buffer containing the name. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/v4l2-core/v4l2-ioctl.c60
1 files changed, 34 insertions, 26 deletions
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index d80d8afba3fb..29c751d86061 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -167,9 +167,11 @@ static void v4l_print_querycap(const void *arg, bool write_only)
167{ 167{
168 const struct v4l2_capability *p = arg; 168 const struct v4l2_capability *p = arg;
169 169
170 pr_cont("driver=%s, card=%s, bus=%s, version=0x%08x, " 170 pr_cont("driver=%.*s, card=%.*s, bus=%.*s, version=0x%08x, "
171 "capabilities=0x%08x, device_caps=0x%08x\n", 171 "capabilities=0x%08x, device_caps=0x%08x\n",
172 p->driver, p->card, p->bus_info, 172 (int)sizeof(p->driver), p->driver,
173 (int)sizeof(p->card), p->card,
174 (int)sizeof(p->bus_info), p->bus_info,
173 p->version, p->capabilities, p->device_caps); 175 p->version, p->capabilities, p->device_caps);
174} 176}
175 177
@@ -177,20 +179,21 @@ static void v4l_print_enuminput(const void *arg, bool write_only)
177{ 179{
178 const struct v4l2_input *p = arg; 180 const struct v4l2_input *p = arg;
179 181
180 pr_cont("index=%u, name=%s, type=%u, audioset=0x%x, tuner=%u, " 182 pr_cont("index=%u, name=%.*s, type=%u, audioset=0x%x, tuner=%u, "
181 "std=0x%08Lx, status=0x%x, capabilities=0x%x\n", 183 "std=0x%08Lx, status=0x%x, capabilities=0x%x\n",
182 p->index, p->name, p->type, p->audioset, p->tuner, 184 p->index, (int)sizeof(p->name), p->name, p->type, p->audioset,
183 (unsigned long long)p->std, p->status, p->capabilities); 185 p->tuner, (unsigned long long)p->std, p->status,
186 p->capabilities);
184} 187}
185 188
186static void v4l_print_enumoutput(const void *arg, bool write_only) 189static void v4l_print_enumoutput(const void *arg, bool write_only)
187{ 190{
188 const struct v4l2_output *p = arg; 191 const struct v4l2_output *p = arg;
189 192
190 pr_cont("index=%u, name=%s, type=%u, audioset=0x%x, " 193 pr_cont("index=%u, name=%.*s, type=%u, audioset=0x%x, "
191 "modulator=%u, std=0x%08Lx, capabilities=0x%x\n", 194 "modulator=%u, std=0x%08Lx, capabilities=0x%x\n",
192 p->index, p->name, p->type, p->audioset, p->modulator, 195 p->index, (int)sizeof(p->name), p->name, p->type, p->audioset,
193 (unsigned long long)p->std, p->capabilities); 196 p->modulator, (unsigned long long)p->std, p->capabilities);
194} 197}
195 198
196static void v4l_print_audio(const void *arg, bool write_only) 199static void v4l_print_audio(const void *arg, bool write_only)
@@ -200,8 +203,9 @@ static void v4l_print_audio(const void *arg, bool write_only)
200 if (write_only) 203 if (write_only)
201 pr_cont("index=%u, mode=0x%x\n", p->index, p->mode); 204 pr_cont("index=%u, mode=0x%x\n", p->index, p->mode);
202 else 205 else
203 pr_cont("index=%u, name=%s, capability=0x%x, mode=0x%x\n", 206 pr_cont("index=%u, name=%.*s, capability=0x%x, mode=0x%x\n",
204 p->index, p->name, p->capability, p->mode); 207 p->index, (int)sizeof(p->name), p->name,
208 p->capability, p->mode);
205} 209}
206 210
207static void v4l_print_audioout(const void *arg, bool write_only) 211static void v4l_print_audioout(const void *arg, bool write_only)
@@ -211,21 +215,22 @@ static void v4l_print_audioout(const void *arg, bool write_only)
211 if (write_only) 215 if (write_only)
212 pr_cont("index=%u\n", p->index); 216 pr_cont("index=%u\n", p->index);
213 else 217 else
214 pr_cont("index=%u, name=%s, capability=0x%x, mode=0x%x\n", 218 pr_cont("index=%u, name=%.*s, capability=0x%x, mode=0x%x\n",
215 p->index, p->name, p->capability, p->mode); 219 p->index, (int)sizeof(p->name), p->name,
220 p->capability, p->mode);
216} 221}
217 222
218static void v4l_print_fmtdesc(const void *arg, bool write_only) 223static void v4l_print_fmtdesc(const void *arg, bool write_only)
219{ 224{
220 const struct v4l2_fmtdesc *p = arg; 225 const struct v4l2_fmtdesc *p = arg;
221 226
222 pr_cont("index=%u, type=%s, flags=0x%x, pixelformat=%c%c%c%c, description='%s'\n", 227 pr_cont("index=%u, type=%s, flags=0x%x, pixelformat=%c%c%c%c, description='%.*s'\n",
223 p->index, prt_names(p->type, v4l2_type_names), 228 p->index, prt_names(p->type, v4l2_type_names),
224 p->flags, (p->pixelformat & 0xff), 229 p->flags, (p->pixelformat & 0xff),
225 (p->pixelformat >> 8) & 0xff, 230 (p->pixelformat >> 8) & 0xff,
226 (p->pixelformat >> 16) & 0xff, 231 (p->pixelformat >> 16) & 0xff,
227 (p->pixelformat >> 24) & 0xff, 232 (p->pixelformat >> 24) & 0xff,
228 p->description); 233 (int)sizeof(p->description), p->description);
229} 234}
230 235
231static void v4l_print_format(const void *arg, bool write_only) 236static void v4l_print_format(const void *arg, bool write_only)
@@ -348,9 +353,9 @@ static void v4l_print_modulator(const void *arg, bool write_only)
348 if (write_only) 353 if (write_only)
349 pr_cont("index=%u, txsubchans=0x%x", p->index, p->txsubchans); 354 pr_cont("index=%u, txsubchans=0x%x", p->index, p->txsubchans);
350 else 355 else
351 pr_cont("index=%u, name=%s, capability=0x%x, " 356 pr_cont("index=%u, name=%.*s, capability=0x%x, "
352 "rangelow=%u, rangehigh=%u, txsubchans=0x%x\n", 357 "rangelow=%u, rangehigh=%u, txsubchans=0x%x\n",
353 p->index, p->name, p->capability, 358 p->index, (int)sizeof(p->name), p->name, p->capability,
354 p->rangelow, p->rangehigh, p->txsubchans); 359 p->rangelow, p->rangehigh, p->txsubchans);
355} 360}
356 361
@@ -361,10 +366,10 @@ static void v4l_print_tuner(const void *arg, bool write_only)
361 if (write_only) 366 if (write_only)
362 pr_cont("index=%u, audmode=%u\n", p->index, p->audmode); 367 pr_cont("index=%u, audmode=%u\n", p->index, p->audmode);
363 else 368 else
364 pr_cont("index=%u, name=%s, type=%u, capability=0x%x, " 369 pr_cont("index=%u, name=%.*s, type=%u, capability=0x%x, "
365 "rangelow=%u, rangehigh=%u, signal=%u, afc=%d, " 370 "rangelow=%u, rangehigh=%u, signal=%u, afc=%d, "
366 "rxsubchans=0x%x, audmode=%u\n", 371 "rxsubchans=0x%x, audmode=%u\n",
367 p->index, p->name, p->type, 372 p->index, (int)sizeof(p->name), p->name, p->type,
368 p->capability, p->rangelow, 373 p->capability, p->rangelow,
369 p->rangehigh, p->signal, p->afc, 374 p->rangehigh, p->signal, p->afc,
370 p->rxsubchans, p->audmode); 375 p->rxsubchans, p->audmode);
@@ -382,9 +387,9 @@ static void v4l_print_standard(const void *arg, bool write_only)
382{ 387{
383 const struct v4l2_standard *p = arg; 388 const struct v4l2_standard *p = arg;
384 389
385 pr_cont("index=%u, id=0x%Lx, name=%s, fps=%u/%u, " 390 pr_cont("index=%u, id=0x%Lx, name=%.*s, fps=%u/%u, "
386 "framelines=%u\n", p->index, 391 "framelines=%u\n", p->index,
387 (unsigned long long)p->id, p->name, 392 (unsigned long long)p->id, (int)sizeof(p->name), p->name,
388 p->frameperiod.numerator, 393 p->frameperiod.numerator,
389 p->frameperiod.denominator, 394 p->frameperiod.denominator,
390 p->framelines); 395 p->framelines);
@@ -504,9 +509,9 @@ static void v4l_print_queryctrl(const void *arg, bool write_only)
504{ 509{
505 const struct v4l2_queryctrl *p = arg; 510 const struct v4l2_queryctrl *p = arg;
506 511
507 pr_cont("id=0x%x, type=%d, name=%s, min/max=%d/%d, " 512 pr_cont("id=0x%x, type=%d, name=%.*s, min/max=%d/%d, "
508 "step=%d, default=%d, flags=0x%08x\n", 513 "step=%d, default=%d, flags=0x%08x\n",
509 p->id, p->type, p->name, 514 p->id, p->type, (int)sizeof(p->name), p->name,
510 p->minimum, p->maximum, 515 p->minimum, p->maximum,
511 p->step, p->default_value, p->flags); 516 p->step, p->default_value, p->flags);
512} 517}
@@ -623,7 +628,8 @@ static void v4l_print_dbg_chip_ident(const void *arg, bool write_only)
623 628
624 pr_cont("type=%u, ", p->match.type); 629 pr_cont("type=%u, ", p->match.type);
625 if (p->match.type == V4L2_CHIP_MATCH_I2C_DRIVER) 630 if (p->match.type == V4L2_CHIP_MATCH_I2C_DRIVER)
626 pr_cont("name=%s, ", p->match.name); 631 pr_cont("name=%.*s, ",
632 (int)sizeof(p->match.name), p->match.name);
627 else 633 else
628 pr_cont("addr=%u, ", p->match.addr); 634 pr_cont("addr=%u, ", p->match.addr);
629 pr_cont("chip_ident=%u, revision=0x%x\n", 635 pr_cont("chip_ident=%u, revision=0x%x\n",
@@ -636,7 +642,8 @@ static void v4l_print_dbg_register(const void *arg, bool write_only)
636 642
637 pr_cont("type=%u, ", p->match.type); 643 pr_cont("type=%u, ", p->match.type);
638 if (p->match.type == V4L2_CHIP_MATCH_I2C_DRIVER) 644 if (p->match.type == V4L2_CHIP_MATCH_I2C_DRIVER)
639 pr_cont("name=%s, ", p->match.name); 645 pr_cont("name=%.*s, ",
646 (int)sizeof(p->match.name), p->match.name);
640 else 647 else
641 pr_cont("addr=%u, ", p->match.addr); 648 pr_cont("addr=%u, ", p->match.addr);
642 pr_cont("reg=0x%llx, val=0x%llx\n", 649 pr_cont("reg=0x%llx, val=0x%llx\n",
@@ -647,8 +654,9 @@ static void v4l_print_dv_enum_presets(const void *arg, bool write_only)
647{ 654{
648 const struct v4l2_dv_enum_preset *p = arg; 655 const struct v4l2_dv_enum_preset *p = arg;
649 656
650 pr_cont("index=%u, preset=%u, name=%s, width=%u, height=%u\n", 657 pr_cont("index=%u, preset=%u, name=%.*s, width=%u, height=%u\n",
651 p->index, p->preset, p->name, p->width, p->height); 658 p->index, p->preset,
659 (int)sizeof(p->name), p->name, p->width, p->height);
652} 660}
653 661
654static void v4l_print_dv_preset(const void *arg, bool write_only) 662static void v4l_print_dv_preset(const void *arg, bool write_only)