Page MenuHomeFreeBSD

bhyve: uniform printf format string newlines
ClosedPublic

Authored by vmaffione on Mon, Nov 25, 9:21 PM.

Details

Summary

Some of the printf statements only use LF to get a newline. However, a CR character is also required for the serial console to print debug logs in a nice way.
Fix those code locations that only use LF, by adding a CR character.

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

vmaffione created this revision.Mon, Nov 25, 9:21 PM

I welcome these changes. The current debug output looks like a mess.
Moreover, part of the files declares (W/D)PRINTF as

#define        WPRINTF(params) printf params

other as

#define WPRINTF(format, arg...) printf(format, ##arg)

So, in some places the call looks like WPRINTF(fmt, args), in other WPRINTF((fmt, args))

After applying the patch, there are still places without using CR. It would be nice to fix them too.

[afedorov:bhyve]# grep -RHn WPRINTF * | grep '\\n' | grep -v '\\r'
pci_ahci.c:344:         WPRINTF("unsupported fis type %d\n", ft);
pci_ahci.c:1791:                WPRINTF("Unsupported cmd:%02x\n", cfis[2]);
pci_ahci.c:1836:                WPRINTF("Not a H2D FIS:%02x\n", cfis[0]);
pci_ahci.c:2123:                WPRINTF("pci_ahci_port: read only registers 0x%"PRIx64"\n", offset);
pci_ahci.c:2198:                WPRINTF("pci_ahci: unknown i/o write offset 0x%"PRIx64"\n", offset);
pci_ahci.c:2297:                WPRINTF("pci_ahci: unknown i/o read offset 0x%"PRIx64"\n",
pci_nvme.c:804:         WPRINTF(("%s: Illegal NSQR value %#x\n", __func__, nqr));
pci_nvme.c:818:         WPRINTF(("%s: Illegal NCQR value %#x\n", __func__, nqr));
rfb.c:359:                              WPRINTF(("zlib[rect] deflate err: %d\n", err));
rfb.c:443:                      WPRINTF(("zlib deflate err: %d\n", err));
rfb.c:905:                      WPRINTF(("rfb unknown cli-code %d!\n", buf[0] & 0xff));
[afedorov:bhyve]# grep -RHn DPRINTF * | grep '\\n' | grep -v '\\r'
audio.c:95:             DPRINTF("dev_name too big\n");
audio.c:104:            DPRINTF("Failed to open dev: %s, errno: %d\n",
audio.c:140:            DPRINTF("Incorrect audio device descriptor for %s\n",
audio.c:149:                    DPRINTF("Failed to reset fd: %d, errno: %d\n",
audio.c:160:            DPRINTF("Fail to set fmt: 0x%x errno: %d\n",
audio.c:167:            DPRINTF("Mismatch format: 0x%x params->format: 0x%x\n",
audio.c:176:            DPRINTF("Fail to set channels: %d errno: %d\n",
audio.c:183:            DPRINTF("Mismatch channels: %d params->channels: %d\n",
audio.c:192:            DPRINTF("Fail to set speed: %d errno: %d\n",
audio.c:199:            DPRINTF("Mismatch rate: %d params->rate: %d\n",
audio.c:208:            DPRINTF("Fail to get audio buf info errno: %d\n", errno);
audio.c:211:    DPRINTF("fragstotal: 0x%x fragsize: 0x%x\n",
audio.c:240:                    DPRINTF("Fail to write to fd: %d, errno: %d\n",
audio.c:276:                    DPRINTF("Fail to write to fd: %d, errno: %d\n",
hda_codec.c:403:        DPRINTF("cad: 0x%x opts: %s\n", hci->cad, opts);
hda_codec.c:423:        DPRINTF("HDA Codec nodes: %d\n", sc->no_nodes);
hda_codec.c:438:                        DPRINTF("Fail to init the output audio player\n");
hda_codec.c:456:                        DPRINTF("Fail to init the input audio player\n");
hda_codec.c:491:        DPRINTF("cad: 0x%x\n", hci->cad);
hda_codec.c:569:                        DPRINTF("Unknown VERB: 0x%x\n", verb);
hda_codec.c:573:        DPRINTF("cad: 0x%x nid: 0x%x verb: 0x%x payload: 0x%x response: 0x%x\n",
hda_codec.c:598:        DPRINTF("run: %d, stream: 0x%x, st->stream: 0x%x dir: %d\n",
hda_codec.c:602:                DPRINTF("Stream not found\n");
hda_codec.c:656:                DPRINTF("Unknown format bits: 0x%x\n",
hda_codec.c:722:        DPRINTF("rate: %d, channels: %d, format: 0x%x\n",
hda_codec.c:781:        DPRINTF("rate: %d, channels: %d, format: 0x%x\n",
hda_codec.c:795:        DPRINTF("%s verb: 0x%x, payload, 0x%x\n", st->actx.name, verb, payload);
hda_codec.c:807:                        DPRINTF("GET_AMP_GAIN_MUTE_LEFT: 0x%x\n", res);
hda_codec.c:810:                        DPRINTF("GET_AMP_GAIN_MUTE_RIGHT: 0x%x\n", res);
hda_codec.c:837:                DPRINTF("st->channel: 0x%x st->stream: 0x%x\n",
hda_codec.c:843:                DPRINTF("Unknown VERB: 0x%x\n", verb);
hda_codec.c:870:        DPRINTF("Start Thread: %s\n", actx->name);
pci_ahci.c:243: DPRINTF("%s(%08x) %08x\n", __func__, mask, sc->is);
pci_ahci.c:285: DPRINTF("%s(%d) %08x/%08x %08x\n", __func__,
pci_ahci.c:1604:                DPRINTF("\n");
pci_ahci.c:1821:        DPRINTF("\ncfis:");
pci_ahci.c:1824:                        DPRINTF("\n");
pci_ahci.c:1827:        DPRINTF("\n");
pci_ahci.c:1830:                DPRINTF("%d@%08"PRIx64"\n", prdt->dbc & 0x3fffff, prdt->dba);
pci_ahci.c:1892:        DPRINTF("%s %d\n", __func__, err);
pci_ahci.c:1952:        DPRINTF("%s exit\n", __func__);
pci_ahci.c:1966:        DPRINTF("%s %d\n", __func__, err);
pci_ahci.c:2014:        DPRINTF("%s exit\n", __func__);
pci_ahci.c:2051:        DPRINTF("pci_ahci_port %d: write offset 0x%"PRIx64" value 0x%"PRIx64"\n",
pci_ahci.c:2152:        DPRINTF("pci_ahci_host: write offset 0x%"PRIx64" value 0x%"PRIx64"\n",
pci_ahci.c:2160:                DPRINTF("pci_ahci_host: read only registers 0x%"PRIx64"\n", offset);
pci_ahci.c:2229:        DPRINTF("pci_ahci_host: read offset 0x%"PRIx64" value 0x%x\n",
pci_ahci.c:2270:        DPRINTF("pci_ahci_port %d: read offset 0x%"PRIx64" value 0x%x\n",
pci_e82545.c:720:               DPRINTF("e1k: s/w reset, ctl %x\n", val);
pci_e82545.c:749:       DPRINTF("rx_ctl - %s RCTL %x, val %x\n",
pci_e82545.c:876:                       DPRINTF("netbe_recv() returned %d\n", len);
pci_hda.c:335:          DPRINTF("Opts too big\n");
pci_hda.c:339:  DPRINTF("opts: %s\n", opts);
pci_hda.c:380:  DPRINTF("opts: %s\n", opts);
pci_hda.c:396:          DPRINTF("play: %s rec: %s\n", play, rec);
pci_hda.c:492:          DPRINTF("This codec does not implement the init function\n");
pci_hda.c:525:  DPRINTF("cad: 0x%x verb: 0x%x\n", cad, verb);
pci_hda.c:531:          DPRINTF("This codec does not implement the command function\n");
pci_hda.c:595:  DPRINTF("Reset the HDA controller registers ...\n");
pci_hda.c:623:  DPRINTF("Reset the HDA stream: 0x%x\n", stream_ind);
pci_hda.c:673:          DPRINTF("Fail to get the guest virtual address\n");
pci_hda.c:677:  DPRINTF("stream: 0x%x bdl_cnt: 0x%x bdl_paddr: 0x%lx\n",
pci_hda.c:693:                  DPRINTF("Fail to get the guest virtual address\n");
pci_hda.c:702:          DPRINTF("bdle: 0x%x bdle_sz: 0x%x\n", i, bdle_sz);
pci_hda.c:709:  DPRINTF("strm: 0x%x, dir: 0x%x\n", strm, dir);
pci_hda.c:733:  DPRINTF("stream: 0x%x, strm: 0x%x, dir: 0x%x\n", stream_ind, strm, dir);
pci_hda.c:774:  DPRINTF("%s size: %d\n", name, p->size);
pci_hda.c:775:  DPRINTF("%s dma_vaddr: %p\n", name, p->dma_vaddr);
pci_hda.c:776:  DPRINTF("%s wp: 0x%x\n", name, p->wp);
pci_hda.c:777:  DPRINTF("%s rp: 0x%x\n", name, p->rp);
pci_hda.c:796:          DPRINTF("Invalid corb size\n");
pci_hda.c:804:  DPRINTF("CORB dma_paddr: %p\n", (void *)corbpaddr);
pci_hda.c:809:          DPRINTF("Fail to get the guest virtual address\n");
pci_hda.c:867:          DPRINTF("Invalid rirb size\n");
pci_hda.c:875:  DPRINTF("RIRB dma_paddr: %p\n", (void *)rirbpaddr);
pci_hda.c:880:          DPRINTF("Fail to get the guest virtual address\n");
pci_hda.c:1025:                 DPRINTF("DMA Position In Buffer dma_paddr: %p\n",
pci_hda.c:1036:                 DPRINTF("DMA Position In Buffer Reset\n");
pci_hda.c:1049: DPRINTF("stream_ind: 0x%x old: 0x%x value: 0x%x\n",
pci_hda.c:1097: DPRINTF("cad: 0x%x\n", hci->cad);
pci_hda.c:1167:         DPRINTF("Invalid stream\n");
pci_hda.c:1183:         DPRINTF("Stream 0x%x stopped\n", stream);
pci_hda.c:1309: DPRINTF("offset: 0x%lx value: 0x%lx\n", offset, value);
pci_hda.c:1328: DPRINTF("offset: 0x%lx value: 0x%lx\n", offset, value);
pci_nvme.c:811:         DPRINTF(("NSQR=%u is greater than max %u\n", sc->num_squeues,
pci_nvme.c:825:         DPRINTF(("NCQR=%u is greater than max %u\n", sc->num_cqueues,
pci_xhci.c:2557:                DPRINTF(("Init port %d 0x%x\n", portn, port->portsc));
pci_xhci.c:2560:                DPRINTF(("Init empty port %d 0x%x\n", portn, port->portsc));
rfb.c:1046:             DPRINTF(("Waiting for rfb client...\n"));
vmaffione updated this revision to Diff 65056.Fri, Nov 29, 6:37 PM

Fixed all the print statements.

markj accepted this revision as: markj.Mon, Dec 2, 5:58 PM
This revision is now accepted and ready to land.Mon, Dec 2, 5:58 PM
This revision was automatically updated to reflect the committed changes.