summaryrefslogtreecommitdiffstats
path: root/drivers/staging/unisys
diff options
context:
space:
mode:
authorKen Cox2014-03-17 16:37:11 +0100
committerGreg Kroah-Hartman2014-03-17 22:46:36 +0100
commita7710336596ecf49b3c1572dd40f4ecfefc6c9ab (patch)
tree25308a1b4a8eefc42552ccc86513460c028db4fa /drivers/staging/unisys
parentStaging: unisys: visorchipset: Clean up sparse warnings in visorchipset code. (diff)
downloadkernel-qcow2-linux-a7710336596ecf49b3c1572dd40f4ecfefc6c9ab.tar.gz
kernel-qcow2-linux-a7710336596ecf49b3c1572dd40f4ecfefc6c9ab.tar.xz
kernel-qcow2-linux-a7710336596ecf49b3c1572dd40f4ecfefc6c9ab.zip
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>
Diffstat (limited to 'drivers/staging/unisys')
-rw-r--r--drivers/staging/unisys/include/timskmodutils.h22
-rw-r--r--drivers/staging/unisys/visorchannel/visorchannel_funcs.c15
-rw-r--r--drivers/staging/unisys/visorutil/procobjecttree.c2
-rw-r--r--drivers/staging/unisys/visorutil/visorkmodutils.c87
4 files changed, 11 insertions, 115 deletions
diff --git a/drivers/staging/unisys/include/timskmodutils.h b/drivers/staging/unisys/include/timskmodutils.h
index ea0ec49f6ac7..2d81d46bf11e 100644
--- a/drivers/staging/unisys/include/timskmodutils.h
+++ b/drivers/staging/unisys/include/timskmodutils.h
@@ -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 ---*
*--------------------------------*/
diff --git a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c
index 611be777c521..f397d8307c5d 100644
--- a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c
+++ b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c
@@ -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) {
diff --git a/drivers/staging/unisys/visorutil/procobjecttree.c b/drivers/staging/unisys/visorutil/procobjecttree.c
index 9c2dd0c6d6f2..1da9958a08c6 100644
--- a/drivers/staging/unisys/visorutil/procobjecttree.c
+++ b/drivers/staging/unisys/visorutil/procobjecttree.c
@@ -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)
diff --git a/drivers/staging/unisys/visorutil/visorkmodutils.c b/drivers/staging/unisys/visorutil/visorkmodutils.c
index ed46208a85ff..ef064692e2fe 100644
--- a/drivers/staging/unisys/visorutil/visorkmodutils.c
+++ b/drivers/staging/unisys/visorutil/visorkmodutils.c
@@ -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.