M
Mac A. Cody
Hello,
I'm encountering a problem with using stdarg that I cannot
figure out. I'm trying to develop a function for a linux
driver module that takes a variable-length sequence of
u8-type values. Below is the function:
#include <stdarg.h>
..
..
..
63 int sn9c102_write_va_regs(struct sn9c102_device* cam,
u16 index, int len, ...)
64 {
65 int res, i;
66 u8 data[32];
67 va_list args;
68
69 va_start(args, len);
70 for (i = 0; i < len; i++) {
71 data = va_arg (args, u8);
72 }
73 va_end(args);
74 res = sn9c102_write_regs(cam, index, data, len);
75 if (res < 0) {
76 DEBUG(3, "Failed to write registers starting at index "
77 "0x%02X, error %d)", index, res)
78 return -1;
79 }
80 return 0;
81 }
When I compile the code, I get the following message:
sonix_pas202b.c: In function `sn9c102_write_va_regs':
sonix_pas202b.c:74: warning: implicit declaration of function
`sn9c102_write_regs'
sonix_pas202b.c:71: warning: `u8' is promoted to `int' when passed
through `...'sonix_pas202b.c:71: warning: (so you should pass `int' not
`u8' to `va_arg')
Why does the warning on line 71 occur? I believe that 'u8'
is typedef'ed somewhere in the linux kernel headers as an
'unsigned char', though I have not verified that yet. Is
there a way of telling 'va_arg' the actual type of 'u8'?
I'm compiling with GCC version 3.2.3 on Slackware Linux 9.1
(kernel 2.4.22).
Thanks,
Mac Cody
I'm encountering a problem with using stdarg that I cannot
figure out. I'm trying to develop a function for a linux
driver module that takes a variable-length sequence of
u8-type values. Below is the function:
#include <stdarg.h>
..
..
..
63 int sn9c102_write_va_regs(struct sn9c102_device* cam,
u16 index, int len, ...)
64 {
65 int res, i;
66 u8 data[32];
67 va_list args;
68
69 va_start(args, len);
70 for (i = 0; i < len; i++) {
71 data = va_arg (args, u8);
72 }
73 va_end(args);
74 res = sn9c102_write_regs(cam, index, data, len);
75 if (res < 0) {
76 DEBUG(3, "Failed to write registers starting at index "
77 "0x%02X, error %d)", index, res)
78 return -1;
79 }
80 return 0;
81 }
When I compile the code, I get the following message:
sonix_pas202b.c: In function `sn9c102_write_va_regs':
sonix_pas202b.c:74: warning: implicit declaration of function
`sn9c102_write_regs'
sonix_pas202b.c:71: warning: `u8' is promoted to `int' when passed
through `...'sonix_pas202b.c:71: warning: (so you should pass `int' not
`u8' to `va_arg')
Why does the warning on line 71 occur? I believe that 'u8'
is typedef'ed somewhere in the linux kernel headers as an
'unsigned char', though I have not verified that yet. Is
there a way of telling 'va_arg' the actual type of 'u8'?
I'm compiling with GCC version 3.2.3 on Slackware Linux 9.1
(kernel 2.4.22).
Thanks,
Mac Cody