fix "Casting operation to a pointer"

The print_param struct's member emit who is used for callback,
the forth parameter of it is used for transmit the private data
of the "print_param".

The type translation between "void *" and private date broke the
violations.

Use the same type to fix it out.

Tracked-On: #861
Signed-off-by: Huihuang Shi <huihuang.shi@intel.com>
Acked-by: Xu Anthony <anthony.xu@intel.com>
This commit is contained in:
Huihuang Shi
2018-11-05 10:40:50 +08:00
committed by lijinxia
parent ad1e2ab678
commit a2516ecc85
3 changed files with 24 additions and 25 deletions

View File

@@ -6,12 +6,13 @@
#include <hypervisor.h>
static void charout(size_t cmd, const char *s_arg, uint32_t sz_arg, void *hnd)
static void
charout(size_t cmd, const char *s_arg, uint32_t sz_arg, struct snprint_param *param)
{
const char *s = s_arg;
uint32_t sz = sz_arg;
/* pointer to an integer to store the number of characters */
size_t *nchars = (size_t *)hnd;
size_t nchars = param->wrtn;
/* working pointer */
const char *p = s;
size_t len;
@@ -23,30 +24,29 @@ static void charout(size_t cmd, const char *s_arg, uint32_t sz_arg, void *hnd)
s += len;
}
*nchars += (s - p);
nchars += (s - p);
} else {
/* fill mode */
*nchars += sz;
nchars += sz;
while (sz != 0U) {
console_putc(s);
sz--;
}
}
param->wrtn = nchars;
}
void vprintf(const char *fmt, va_list args)
{
/* struct to store all necessary parameters */
struct print_param param;
/* argument fo charout() */
size_t nchars = 0;
struct snprint_param snparam;
/* initialize parameters */
(void)memset(&snparam, 0U, sizeof(snparam));
(void)memset(&param, 0U, sizeof(param));
param.emit = charout;
param.data = &nchars;
param.data = &snparam;
/* execute the printf() */
do_print(fmt, &param, args);