Linux Serial subsystem development
 help / color / mirror / Atom feed
* [Suggestion] drivers/tty/serial: sprintf for filename[32].
@ 2012-12-01 10:01 Chen Gang
  0 siblings, 0 replies; only message in thread
From: Chen Gang @ 2012-12-01 10:01 UTC (permalink / raw)
  To: Alan Cox; +Cc: linux-serial

Hello Alan Cox:

in drives/tty/serial/ucc_uart.c:
  at line 1231, the filename buffer length is 32.
  at line 1242, "fsl_qe_ucode_uart_%u_%u%u.bin" is 23 + 3*%u.
  at line 1237, after call soc_info. soc within 4 bytes, rev_h within 2 bytes, rev_l within 2 bytes.

my suggestion is:
  use "fsl_qe_ucode_uart_%.4u_%.2u%.2u.bin" instead of "fsl_qe_ucode_uart_%u_%u%u.bin";
  or use "char filename[64]" instead of "char filename[32]".
  please give your choice (or provide new choice).

  it is not a bug, it is only to make source code clearer or extensible.

  thanks.


1231                 } else {
1232                         char filename[32];
1233                         unsigned int soc;
1234                         unsigned int rev_h;
1235                         unsigned int rev_l;
1236 
1237                         soc = soc_info(&rev_h, &rev_l);
1238                         if (!soc) {
1239                                 dev_err(&ofdev->dev, "unknown CPU model\n");
1240                                 return -ENXIO;
1241                         }
1242                         sprintf(filename, "fsl_qe_ucode_uart_%u_%u%u.bin",
1243                                 soc, rev_h, rev_l);
1244 
1245                         dev_info(&ofdev->dev, "waiting for firmware %s\n",
1246                                 filename);
1247 



-- 
Chen Gang

Asianux Corporation

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-12-01 10:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-01 10:01 [Suggestion] drivers/tty/serial: sprintf for filename[32] Chen Gang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox