Staging: unisys: visorutil: Clean up sparse warnings in visorutil code
Clean up code to get rid of sparse warnings. Also fixed variable length arrays declared on the stack by removing visor_hexDumpToBuffer() and using hex_dump_to_buffer() instead. Signed-off-by: Ken Cox <jkc@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Родитель
bd5b9b32d2
Коммит
a771033659
|
@ -24,28 +24,6 @@ void *kmalloc_kernel(size_t siz);
|
|||
void myprintk(const char *myDrvName, const char *devname,
|
||||
const char *template, ...);
|
||||
|
||||
/** Print the hexadecimal contents of a data buffer to a supplied print buffer.
|
||||
* @param dest the print buffer where text characters will be
|
||||
* written
|
||||
* @param destSize the maximum number of bytes that can be written
|
||||
* to #dest
|
||||
* @param src the buffer that contains the data that is to be
|
||||
* hex-dumped
|
||||
* @param srcLen the number of bytes at #src to be hex-dumped
|
||||
* @param bytesToDumpPerLine output will be formatted such that at most this
|
||||
* many of the input data bytes will be represented
|
||||
* on each line of output
|
||||
* @return the number of text characters written to #dest
|
||||
* (not including the trailing '\0' byte)
|
||||
* @ingroup internal
|
||||
*/
|
||||
int visor_hexDumpToBuffer(char *dest,
|
||||
int destSize,
|
||||
char *prefix,
|
||||
char *src,
|
||||
int srcLen,
|
||||
int bytesToDumpPerLine);
|
||||
|
||||
/*--------------------------------*
|
||||
*--- GENERAL MESSAGEQ STUFF ---*
|
||||
*--------------------------------*/
|
||||
|
|
|
@ -603,9 +603,9 @@ void
|
|||
visorchannel_dump_section(VISORCHANNEL *chan, char *s,
|
||||
int off, int len, struct seq_file *seq)
|
||||
{
|
||||
char *buf = NULL, *fmtbuf = NULL;
|
||||
char *buf, *tbuf, *fmtbuf;
|
||||
int fmtbufsize = 0;
|
||||
int i = 0;
|
||||
int i;
|
||||
int errcode = 0;
|
||||
|
||||
fmtbufsize = 100 * COVQ(len, 16);
|
||||
|
@ -621,9 +621,14 @@ visorchannel_dump_section(VISORCHANNEL *chan, char *s,
|
|||
goto Away;
|
||||
}
|
||||
seq_printf(seq, "channel %s:\n", s);
|
||||
visor_hexDumpToBuffer(fmtbuf, fmtbufsize, " ", buf, len, 16);
|
||||
for (i = 0; fmtbuf[i] != '\0'; i++)
|
||||
seq_printf(seq, "%c", fmtbuf[i]);
|
||||
tbuf = buf;
|
||||
while (len > 0) {
|
||||
i = (len < 16) ? len : 16;
|
||||
hex_dump_to_buffer(tbuf, i, 16, 1, fmtbuf, fmtbufsize, TRUE);
|
||||
seq_printf(seq, "%s\n", fmtbuf);
|
||||
tbuf += 16;
|
||||
len -= 16;
|
||||
}
|
||||
|
||||
Away:
|
||||
if (buf != NULL) {
|
||||
|
|
|
@ -149,7 +149,7 @@ MYPROCTYPE *visor_proc_CreateType(struct proc_dir_entry *procDirRoot,
|
|||
type->nNames = 0;
|
||||
type->show_property = show_property;
|
||||
type->procDirRoot = procDirRoot;
|
||||
if (type->propertyNames != 0)
|
||||
if (type->propertyNames != NULL)
|
||||
while (type->propertyNames[type->nProperties] != NULL)
|
||||
type->nProperties++;
|
||||
while (type->name[type->nNames] != NULL)
|
||||
|
|
|
@ -20,93 +20,6 @@
|
|||
|
||||
#define MYDRVNAME "timskmodutils"
|
||||
|
||||
BOOL Debug_Malloc_Enabled = FALSE;
|
||||
|
||||
/** Print the hexadecimal contents of a data buffer to a supplied print buffer.
|
||||
* @param dest the print buffer where text characters will
|
||||
* be written
|
||||
* @param destSize the maximum number of bytes that can be written
|
||||
* to #dest
|
||||
* @param src the buffer that contains the data that is to be
|
||||
* hex-dumped
|
||||
* @param srcLen the number of bytes at #src to be hex-dumped
|
||||
* @param bytesToDumpPerLine output will be formatted such that at most
|
||||
* this many of the input data bytes will be
|
||||
* represented on each line of output
|
||||
* @return the number of text characters written to #dest
|
||||
* (not including the trailing '\0' byte)
|
||||
* @ingroup internal
|
||||
*/
|
||||
int visor_hexDumpToBuffer(char *dest, int destSize, char *prefix, char *src,
|
||||
int srcLen, int bytesToDumpPerLine)
|
||||
{
|
||||
int i = 0;
|
||||
int pos = 0;
|
||||
char printable[bytesToDumpPerLine + 1];
|
||||
char hex[(bytesToDumpPerLine * 3) + 1];
|
||||
char *line = NULL;
|
||||
int linesize = 1000;
|
||||
int linelen = 0;
|
||||
int currentlen = 0;
|
||||
char emptystring[] = "";
|
||||
char *pfx = prefix;
|
||||
int baseaddr = 0;
|
||||
int rc = 0;
|
||||
|
||||
line = vmalloc(linesize);
|
||||
if (line == NULL)
|
||||
RETINT(currentlen);
|
||||
|
||||
if (pfx == NULL || (strlen(pfx) > 50))
|
||||
pfx = emptystring;
|
||||
memset(hex, ' ', bytesToDumpPerLine * 3);
|
||||
hex[bytesToDumpPerLine * 3] = '\0';
|
||||
memset(printable, ' ', bytesToDumpPerLine);
|
||||
printable[bytesToDumpPerLine] = '\0';
|
||||
if (destSize > 0)
|
||||
dest[0] = '\0';
|
||||
|
||||
for (i = 0; i < srcLen; i++) {
|
||||
pos = i % bytesToDumpPerLine;
|
||||
if ((pos == 0) && (i > 0)) {
|
||||
hex[bytesToDumpPerLine*3] = '\0';
|
||||
linelen = sprintf(line, "%s%-6.6x %s %s\n", pfx,
|
||||
baseaddr, hex, printable);
|
||||
if ((currentlen) + (linelen) >= destSize)
|
||||
RETINT(currentlen);
|
||||
strcat(dest, line);
|
||||
currentlen += linelen;
|
||||
memset(hex, ' ', bytesToDumpPerLine * 3);
|
||||
memset(printable, ' ', bytesToDumpPerLine);
|
||||
baseaddr = i;
|
||||
}
|
||||
sprintf(hex + (pos * 3), "%-2.2x ", (uint8_t)(src[i]));
|
||||
*(hex + (pos * 3) + 3) = ' '; /* get rid of null */
|
||||
if (((uint8_t)(src[i]) >= ' ') && (uint8_t)(src[i]) < 127)
|
||||
printable[pos] = src[i];
|
||||
else
|
||||
printable[pos] = '.';
|
||||
}
|
||||
pos = i%bytesToDumpPerLine;
|
||||
if (i > 0) {
|
||||
hex[bytesToDumpPerLine * 3] = '\0';
|
||||
linelen = sprintf(line, "%s%-6.6x %s %s\n",
|
||||
pfx, baseaddr, hex, printable);
|
||||
if ((currentlen) + (linelen) >= destSize)
|
||||
RETINT(currentlen);
|
||||
strcat(dest, line);
|
||||
currentlen += linelen;
|
||||
}
|
||||
RETINT(currentlen);
|
||||
|
||||
Away:
|
||||
if (line)
|
||||
vfree(line);
|
||||
return rc;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(visor_hexDumpToBuffer);
|
||||
|
||||
|
||||
/** Callers to interfaces that set __GFP_NORETRY flag below
|
||||
* must check for a NULL (error) result as we are telling the
|
||||
* kernel interface that it is okay to fail.
|
||||
|
|
Загрузка…
Ссылка в новой задаче