MCPcopy Create free account
hub / github.com/ading2210/linuxpdf / marshall

Function marshall

tinyemu/virtio.c:1761–1861  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1759#endif /* DEBUG_VIRTIO */
1760
1761static int marshall(VIRTIO9PDevice *s,
1762 uint8_t *buf1, int max_len, const char *fmt, ...)
1763{
1764 va_list ap;
1765 int c;
1766 uint32_t val;
1767 uint64_t val64;
1768 uint8_t *buf, *buf_end;
1769
1770#ifdef DEBUG_VIRTIO
1771 if (s->common.debug & VIRTIO_DEBUG_9P)
1772 printf(" ->");
1773#endif
1774 va_start(ap, fmt);
1775 buf = buf1;
1776 buf_end = buf1 + max_len;
1777 for(;;) {
1778 c = *fmt++;
1779 if (c == '\0')
1780 break;
1781 switch(c) {
1782 case 'b':
1783 assert(buf + 1 <= buf_end);
1784 val = va_arg(ap, int);
1785#ifdef DEBUG_VIRTIO
1786 if (s->common.debug & VIRTIO_DEBUG_9P)
1787 printf(" b=%d", val);
1788#endif
1789 buf[0] = val;
1790 buf += 1;
1791 break;
1792 case 'h':
1793 assert(buf + 2 <= buf_end);
1794 val = va_arg(ap, int);
1795#ifdef DEBUG_VIRTIO
1796 if (s->common.debug & VIRTIO_DEBUG_9P)
1797 printf(" h=%d", val);
1798#endif
1799 put_le16(buf, val);
1800 buf += 2;
1801 break;
1802 case 'w':
1803 assert(buf + 4 <= buf_end);
1804 val = va_arg(ap, int);
1805#ifdef DEBUG_VIRTIO
1806 if (s->common.debug & VIRTIO_DEBUG_9P)
1807 printf(" w=%d", val);
1808#endif
1809 put_le32(buf, val);
1810 buf += 4;
1811 break;
1812 case 'd':
1813 assert(buf + 8 <= buf_end);
1814 val64 = va_arg(ap, uint64_t);
1815#ifdef DEBUG_VIRTIO
1816 if (s->common.debug & VIRTIO_DEBUG_9P)
1817 printf(" d=%" PRId64, val64);
1818#endif

Callers 3

virtio_9p_send_errorFunction · 0.85
virtio_9p_open_replyFunction · 0.85
virtio_9p_recv_requestFunction · 0.85

Calls 3

put_le16Function · 0.85
put_le32Function · 0.85
put_le64Function · 0.85

Tested by

no test coverage detected