Staging: unisys: visorutil: Clean up sparse warnings in visorutil code
authorKen Cox <jkc@redhat.com>
Mon, 17 Mar 2014 15:37:11 +0000 (10:37 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 17 Mar 2014 21:46:36 +0000 (14:46 -0700)
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>
drivers/staging/unisys/include/timskmodutils.h
drivers/staging/unisys/visorchannel/visorchannel_funcs.c
drivers/staging/unisys/visorutil/procobjecttree.c
drivers/staging/unisys/visorutil/visorkmodutils.c

index ea0ec49f6ac7014622393b39131b8d7592ecb123..2d81d46bf11e7f6e9e9386350b779575bdf0cce9 100644 (file)
@@ -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  ---*
  *--------------------------------*/
index 611be777c5215584725123d015fe0fe9d9b65ea7..f397d8307c5d605aa8fba06c61f8855cfcf0e24d 100644 (file)
@@ -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) {
index 9c2dd0c6d6f29d6e6df49e4c1e58da500cfe8927..1da9958a08c6d70812a4e093a6e82ec3cbb7cc32 100644 (file)
@@ -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)
index ed46208a85ffdfe3c7ea42784a1adc3ae986ec59..ef064692e2fe370ce3f7dee8b88be28c141709fc 100644 (file)
 
 #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.