On 01.12.23 20:30, Jason Andryuk wrote:
On Fri, Nov 10, 2023 at 1:41 PM Juergen Gross <[email protected]> wrote:+static void fill_buffer(struct ring *ring, uint8_t cmd, uint16_t tag, + const char *fmt, ...) +{ + struct p9_header *hdr = ring->buffer; + void *data = hdr + 1; + const char *f; + const void *par; + const char *str_val; + const struct p9_qid *qid; + unsigned int len; + va_list ap; + unsigned int array_sz = 0; + unsigned int elem_sz = 0; + + hdr->cmd = cmd; + hdr->tag = tag; + + va_start(ap, fmt); + + for ( f = fmt; *f; f++ ) + { + if ( !array_sz ) + par = va_arg(ap, const void *); + else + { + par += elem_sz; + array_sz--; + } + + switch ( *f ) + { + case 'a': + f++; + if ( !*f || array_sz ) + fmt_err(fmt); + array_sz = *(const unsigned int *)par; + if ( array_sz > 0xffff ) + { + syslog(LOG_CRIT, "array size %u in fill_buffer()", array_sz); + exit(1); + } + *(__packed uint16_t *)data = array_sz;Compiling on Fedora 39, gcc 13.2.1: io.c: In function ‘fill_buffer’: io.c:233:13: error: ‘packed’ attribute ignored for type ‘uint16_t *’ {aka ‘short unsigned int *’} [-Werror=attributes] 233 | *(__packed uint16_t *)data = array_sz; | ^ For all these uses of __packed.
Meh. Okay, will add get_unaligned() and put_unaligned() for that purpose dealing with the issue in a clean way. Juergen
OpenPGP_0xB0DE9DD628BF132F.asc
Description: OpenPGP public key
OpenPGP_signature.asc
Description: OpenPGP digital signature
