Replace few more cases where %D format string is used.
authorAntonio Huete Jimenez <tuxillo@quantumachine.net>
Tue, 22 Jan 2013 18:49:00 +0000 (19:49 +0100)
committerAntonio Huete Jimenez <tuxillo@quantumachine.net>
Tue, 22 Jan 2013 18:54:34 +0000 (19:54 +0100)
Also remove a reference to %D in kvcprintf's comment.

sys/bus/u4b/usb_msctest.c
sys/bus/u4b/wlan/if_zyd.c
sys/dev/raid/amr/amr_cam.c
sys/dev/raid/mly/mly.c
sys/kern/subr_prf.c

index 43e39eb..9657a5d 100644 (file)
@@ -465,6 +465,10 @@ bbb_command_start(struct bbb_transfer *sc, uint8_t dir, uint8_t lun,
     void *data_ptr, size_t data_len, void *cmd_ptr, size_t cmd_len,
     usb_timeout_t data_timeout)
 {
+#ifdef USB_DEBUG
+       char hexstr[HEX_NCPYLEN(CBWCDBLENGTH)];
+#endif
+
        sc->lun = lun;
        sc->dir = data_len ? dir : DIR_NONE;
        sc->data_ptr = data_ptr;
@@ -475,8 +479,8 @@ bbb_command_start(struct bbb_transfer *sc, uint8_t dir, uint8_t lun,
        sc->cmd_len = cmd_len;
        memset(&sc->cbw.CBWCDB, 0, sizeof(sc->cbw.CBWCDB));
        memcpy(&sc->cbw.CBWCDB, cmd_ptr, cmd_len);
-       DPRINTFN(1, "SCSI cmd = %*D\n", (int)cmd_len, (char *)sc->cbw.CBWCDB, ":");
-
+       DPRINTFN(1, "SCSI cmd = %s\n", hexncpy(sc->cbw.CBWCDB, cmd_len,
+               hexstr, HEX_NCPYLEN(cmd_len), ":"));
        lockmgr(&sc->lock, LK_EXCLUSIVE);
        usbd_transfer_start(sc->xfer[sc->state]);
 
index 2f03189..e232b35 100644 (file)
@@ -19,9 +19,6 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
 /*
  * ZyDAS ZD1211/ZD1211B USB WLAN driver.
  */
@@ -620,6 +617,7 @@ zyd_intr_read_callback(struct usb_xfer *xfer, usb_error_t error)
        struct usb_page_cache *pc;
        int datalen;
        int actlen;
+       char hexstr[HEX_NCPYLEN(64)];
 
        usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
 
@@ -685,15 +683,17 @@ zyd_intr_read_callback(struct usb_xfer *xfer, usb_error_t error)
                                /* copy answer into caller-supplied buffer */
                                memcpy(rqp->odata, cmd->data, rqp->olen);
                                DPRINTF(sc, ZYD_DEBUG_CMD,
-                                   "command %p complete, data = %*D \n",
-                                   rqp, rqp->olen, (char *)rqp->odata, ":");
+                                   "command %p complete, data = %s \n",
+                                   rqp, hexncpy(rqp->odata, rqp->olen, hexstr,
+                                       HEX_NCPYLEN(rqp->olen), ":"));
                                wakeup(rqp);    /* wakeup caller */
                                break;
                        }
                        if (rqp == NULL) {
                                device_printf(sc->sc_dev,
-                                   "unexpected IORD notification %*D\n",
-                                   datalen, cmd->data, ":");
+                                   "unexpected IORD notification %s\n",
+                                   hexncpy(cmd->data, datalen, hexstr,
+                                       HEX_NCPYLEN(datalen), ":"));
                        }
                        break;
                }
@@ -778,14 +778,17 @@ zyd_cmd(struct zyd_softc *sc, uint16_t code, const void *idata, int ilen,
        struct zyd_cmd cmd;
        struct zyd_rq rq;
        int error;
+#ifdef USB_DEBUG
+       char hexstr[HEX_NCPYLEN(64)];
+#endif
 
        if (ilen > sizeof(cmd.data))
                return (EINVAL);
 
        cmd.code = htole16(code);
        memcpy(cmd.data, idata, ilen);
-       DPRINTF(sc, ZYD_DEBUG_CMD, "sending cmd %p = %*D\n",
-           &rq, ilen, idata, ":");
+       DPRINTF(sc, ZYD_DEBUG_CMD, "sending cmd %p = %s\n", &rq,
+           hexncpy(idata, ilen, hexstr, HEX_NCPYLEN(ilen), ":"));
 
        rq.cmd = &cmd;
        rq.idata = idata;
index 7215ad5..51aa31c 100644 (file)
@@ -550,6 +550,9 @@ amr_cam_complete(struct amr_command *ac)
        struct ccb_scsiio               *csio;
        struct scsi_inquiry_data        *inq;
        int                             scsi_status, cdb0;
+#ifdef AMR_DEBUG
+       char                            hexstr[HEX_NCPYLEN(16)];
+#endif
 
        ap = &ac->ac_ccb->ccb_pthru;
        aep = &ac->ac_ccb->ccb_epthru;
@@ -620,8 +623,8 @@ amr_cam_complete(struct amr_command *ac)
 
 out:
        if ((csio->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE)
-               debug(2, "%*D\n", imin(csio->dxfer_len, 16), csio->data_ptr,
-                   " ");
+               debug(2, "%s\n", hexncpy(csio->data_ptr, imin(csio->dxfer_len, 16),
+                       hexstr, HEX_NCPYLEN(imin(csio->dxfer_len, 16)), " "));
 
        lockmgr(&ac->ac_sc->amr_list_lock, LK_EXCLUSIVE);
        xpt_done((union ccb *)csio);
index 6daa880..890cfff 100644 (file)
@@ -2622,6 +2622,7 @@ mly_print_packet(struct mly_command *mc)
     struct mly_command_scsi_large      *sl = (struct mly_command_scsi_large *)mc->mc_packet;
     struct mly_command_ioctl           *io = (struct mly_command_ioctl *)mc->mc_packet;
     int                                        transfer;
+    char                               hexstr[HEX_NCPYLEN(MLY_CMD_SCSI_SMALL_CDB)];
 
     mly_printf(sc, "   command_id           %d\n", ge->command_id);
     mly_printf(sc, "   opcode               %d\n", ge->opcode);
@@ -2648,7 +2649,8 @@ mly_print_packet(struct mly_command *mc)
     case MDACMD_SCSIPT:
     case MDACMD_SCSI:
        mly_printf(sc, "   cdb length           %d\n", ss->cdb_length);
-       mly_printf(sc, "   cdb                  %*D\n", ss->cdb_length, ss->cdb, " ");
+       mly_printf(sc, "   cdb                  %s\n", hexncpy(ss->cdb, ss->cdb_length,
+               hexstr, HEX_NCPYLEN(ss->cdb_length), " ");
        transfer = 1;
        break;
     case MDACMD_SCSILC:
index 9715ab8..b56cddb 100644 (file)
@@ -553,10 +553,6 @@ ksprintn(char *nbuf, uintmax_t num, int base, int *lenp, int upper)
  * would produce output:
  *
  *     reg=3<BITTWO,BITONE>
- *
- * XXX:  %D  -- Hexdump, takes pointer and separator string:
- *             ("%6D", ptr, ":")   -> XX:XX:XX:XX:XX:XX
- *             ("%*D", len, ptr, " " -> XX XX XX XX ...
  */
 
 #define PCHAR(c) {int cc=(c); if(func) (*func)(cc,arg); else *d++=cc; retval++;}