Example #1
0
void
_log_stderr(const char *fmt, ...)
{
    struct logger *l = &logger;
    int len, size, errno_save;
    char buf[4 * LOG_MAX_LEN];
    va_list args;
    ssize_t n;

    errno_save = errno;
    len = 0;                /* length of output buffer */
    size = 4 * LOG_MAX_LEN; /* size of output buffer */

    va_start(args, fmt);
    len += vscnprintf(buf, size, fmt, args);
    va_end(args);

    buf[len++] = '\n';

    n = clive_write(STDERR_FILENO, buf, len);
    if (n < 0) {
        l->nerror++;
    }

    errno = errno_save;
}
Example #2
0
static void printl(const char *fmt, ...)
{
	va_list args;
	int len;
	struct timeval now;
	char tbuf[256];

	va_start(args, fmt);
	do_gettimeofday(&now);

	now.tv_sec -= tcpw.tstart.tv_sec;
	now.tv_usec -= tcpw.tstart.tv_usec;
	if (now.tv_usec < 0) {
		--now.tv_sec;
		now.tv_usec += 1000000;
	}

	len = sprintf(tbuf, "%lu.%06lu ",
		      (unsigned long) now.tv_sec,
		      (unsigned long) now.tv_usec);
	len += vscnprintf(tbuf+len, sizeof(tbuf)-len, fmt, args);
	va_end(args);

	kfifo_put(tcpw.fifo, tbuf, len);
	wake_up(&tcpw.wait);
}
Example #3
0
void __trace_note_message(struct blk_trace *bt, const char *fmt, ...)
{
	int n;
	va_list args;
	unsigned long flags;
	char *buf;

	if (unlikely(bt->trace_state != Blktrace_running &&
		     !blk_tracer_enabled))
		return;

	/*
	 * If the BLK_TC_NOTIFY action mask isn't set, don't send any note
	 * message to the trace.
	 */
	if (!(bt->act_mask & BLK_TC_NOTIFY))
		return;

	local_irq_save(flags);
	buf = per_cpu_ptr(bt->msg_data, smp_processor_id());
	va_start(args, fmt);
	n = vscnprintf(buf, BLK_TN_MAX_MSG, fmt, args);
	va_end(args);

	trace_note(bt, 0, BLK_TN_MESSAGE, buf, n);
	local_irq_restore(flags);
}
Example #4
0
static int dprintk(int level, const char *fmt, ...)
{
	static char printk_buf[1024];
	static long prevticks;
	static int invocation;
	va_list args;
	int len;

	if (level > USB_S3C2410_DEBUG_LEVEL)
		return 0;

	if (s3c2410_ticks != prevticks) {
		prevticks = s3c2410_ticks;
		invocation = 0;
	}

	len = scnprintf(printk_buf,
			sizeof(printk_buf), "%1lu.%02d USB: ",
			prevticks, invocation++);

	va_start(args, fmt);
	len = vscnprintf(printk_buf+len,
			sizeof(printk_buf)-len, fmt, args);
	va_end(args);

	return pr_debug("%s", printk_buf);
}
Example #5
0
int printf(const char *fmt, ...)
{
	va_list args;
	uint i;
	char printbuffer[CONFIG_SYS_PBSIZE];

#ifndef CONFIG_PRE_CONSOLE_BUFFER
	if (!gd->have_console)
#ifdef CONFIG_SPL_SEMIHOSTING_SUPPORT
		;	/* printf can be done with semihosting */
#else
		return 0;
#endif	/* CONFIG_SPL_SEMIHOSTING_SUPPORT */
#endif	/* CONFIG_PRE_CONSOLE_BUFFER */

	va_start(args, fmt);

	/* For this to work, printbuffer must be larger than
	 * anything we ever want to print.
	 */
	i = vscnprintf(printbuffer, sizeof(printbuffer), fmt, args);
	va_end(args);

	/* Print the string */
	puts(printbuffer);
	return i;
}
/*
  * Function: report
  * Description: Packet and Send data to userspace by kstate
  * Input: mask -- message mask
  *        fmt -- string
  * Return: -1--failed, 0--success
**/
static int report(int mask, va_list args, const char *fmt)
{
	int ret = -1;
	struct kcollect_info info;
	struct timeval time;
	int length = 0;
	size_t info_len = 0;

	memset(&info, 0, sizeof(info));
	length = vscnprintf(info.buffer, KCOLLECT_BUFFER_SIZE - 1, fmt, args);
	if (length > 0) {
		info.mask = mask;
		info.len = length + 1;
		if (!get_ktime_disable()) {
			do_gettimeofday(&time);
		}
		info.tv_sec = (u32)time.tv_sec;
		info.tv_usec = (u32)time.tv_usec;
		info_len = sizeof(info) - KCOLLECT_BUFFER_SIZE + length + 1;
		ret = kstate(CHANNEL_ID_KCOLLECT, PACKET_TAG_KCOLLECT, (char*)&info, info_len);
		if (ret < 0) {
			pr_err("hw_kcollect %s: kstate error\n", __func__);
			ret = -1;
		}
	}
	pr_debug("hw_kcollect %s: length=%d mask=%d\n", __func__, length, mask);
	return ret;
}
Example #7
0
static void early_vprintk(const char *fmt, va_list ap)
{
	if (early_console) {
		char buf[512];
		int n = vscnprintf(buf, sizeof(buf), fmt, ap);

		early_console->write(early_console, buf, n);
	}
}
void _mali_osk_ctxprintf(_mali_osk_print_ctx *print_ctx, const char *fmt, ...)
{
	va_list args;
	char buf[512];

	va_start(args, fmt);
	vscnprintf(buf, 512, fmt, args);
	seq_printf(print_ctx, buf);
	va_end(args);
}
Example #9
0
/**
 * gpio_requestf() - [COMPAT] Request GPIO
 * @gpio:	GPIO number
 * @fmt:	Format string for the requested GPIO
 * @...:	Arguments for the printf() format string
 *
 * This function implements the API that's compatible with current
 * GPIO API used in U-Boot. The request is forwarded to particular
 * GPIO driver. Returns 0 on success, negative value on error.
 */
int gpio_requestf(unsigned gpio, const char *fmt, ...)
{
	va_list args;
	char buf[40];

	va_start(args, fmt);
	vscnprintf(buf, sizeof(buf), fmt, args);
	va_end(args);
	return gpio_request(gpio, buf);
}
Example #10
0
static int dm_gpio_requestf(struct gpio_desc *desc, const char *fmt, ...)
{
	va_list args;
	char buf[40];

	va_start(args, fmt);
	vscnprintf(buf, sizeof(buf), fmt, args);
	va_end(args);
	return dm_gpio_request(desc, buf);
}
Example #11
0
asmlinkage void early_printk(const char *fmt, ...)
{
	char buf[512];
	int n;
	va_list ap;

	va_start(ap, fmt);
	n = vscnprintf(buf, sizeof(buf), fmt, ap);
	early_console->write(early_console, buf, n, 0);
	va_end(ap);
}
Example #12
0
static void dbg(const char *fmt, ...)
{
	va_list va;
	char buff[256];

	va_start(va, fmt);
	vscnprintf(buff, sizeof(buff), fmt, va);
	va_end(va);

	printascii(buff);
}
u32 _mali_osk_snprintf(char *buf, u32 size, const char *fmt, ...)
{
	int res;
	va_list args;
	va_start(args, fmt);

	res = vscnprintf(buf, (size_t)size, fmt, args);

	va_end(args);
	return res;
}
static u32 write_str(struct debug_buffer *buffer, const char *fmt, ...)
{
	va_list args;
	u32 size;
	va_start(args, fmt);
	size = vscnprintf(buffer->curr, MAX_DBG_BUF_SIZE - 1, fmt, args);
	va_end(args);
	buffer->curr += size;
	buffer->filled_size += size;
	return size;
}
Example #15
0
void notrace prom_printf(const char *fmt, ...)
{
	va_list args;
	int i;

	va_start(args, fmt);
	i = vscnprintf(ppbuf, sizeof(ppbuf), fmt, args);
	va_end(args);

	prom_write(ppbuf, i);
}
/**
    @function: int srecorder_snprintf(char *buf, size_t size, const char *fmt, ...)
    @brief: 按指定格式输出字符串到指定缓存中。

    @param: buf 缓存
    @param: size 缓存空间大小
    @param: fmt 字符串格式

    @return: 写入缓存的字节数

    @note:
*/
int srecorder_snprintf(char *buf, size_t size, const char *fmt, ...)
{
    va_list args;
    int i = 0;

    va_start(args, fmt);
    i = vscnprintf(buf, size, fmt, args);
    va_end(args);

    return i;
}
Example #17
0
static int
scnprintf(char *buf, size_t size, const char *fmt, ...)
{
    va_list args;
    int n;

    va_start(args, fmt);
    n = vscnprintf(buf, size, fmt, args);
    va_end(args);

    return n;
}
void hsu_early_printk(const char *fmt, ...)
{
	char buf[512];
	int n;
	va_list ap;

	va_start(ap, fmt);
	n = vscnprintf(buf, 512, fmt, ap);
	va_end(ap);

	early_hsu_console.write(&early_hsu_console, buf, n);
}
Example #19
0
int vprintf(const char *fmt, va_list args)
{
	char printk_buf[MAX_PRINTF_SIZE];
	int printed_len;

	printed_len = vscnprintf(printk_buf, sizeof(printk_buf), fmt, args);
	printk_buf[printed_len] = '\0';										/* vscnprintf函数返回的值永远不会大于printk_buf数组的长度 */
	console_write(printk_buf, printed_len);

	return printed_len;

}
Example #20
0
File: cfe.c Project: aircross/ray
int cfe_vprintk(const char *fmt, va_list args)
{
	static char buffer[1024];
	static DEFINE_SPINLOCK(lock);
	static const char pfx[] = "CFE-console: ";
	static const size_t pfx_len = sizeof(pfx) - 1;
	unsigned long flags;
	int len, cnt, pos;
	int handle;
	int res;

	if (!cfe_present())
		return -ENODEV;

	spin_lock_irqsave(&lock, flags);
	handle = cfe_getstdhandle(CFE_STDHANDLE_CONSOLE);
	if (CFE_ISERR(handle)) {
		len = -EIO;
		goto out;
	}
	strcpy(buffer, pfx);
	len = vscnprintf(buffer + pfx_len,
			 sizeof(buffer) - pfx_len - 2,
			 fmt, args);
	len += pfx_len;
	/* The CFE console requires CR-LF line-ends.
	 * Add a CR, if we only terminate lines with a LF.
	 * This does only fix CR-LF at the end of the string.
	 * So for multiple lines, use multiple cfe_vprintk calls.
	 */
	if (len > 1 &&
	    buffer[len - 1] == '\n' && buffer[len - 2] != '\r') {
		buffer[len - 1] = '\r';
		buffer[len] = '\n';
		len += 1;
	}
	cnt = len;
	pos = 0;
	while (cnt > 0) {
		res = cfe_write(handle, buffer + pos, len - pos);
		if (CFE_ISERR(res)) {
			len = -EIO;
			goto out;
		}
		cnt -= res;
		pos += res;
	}
out:
	spin_unlock_irqrestore(&lock, flags);

	return len;
}
Example #21
0
static int wl1271_format_buffer(char __user *userbuf, size_t count,
				    loff_t *ppos, char *fmt, ...)
{
	va_list args;
	char buf[DEBUGFS_FORMAT_BUFFER_SIZE];
	int res;

	va_start(args, fmt);
	res = vscnprintf(buf, sizeof(buf), fmt, args);
	va_end(args);

	return simple_read_from_buffer(userbuf, count, ppos, buf, res);
}
Example #22
0
int debug_log(struct bat_priv *bat_priv, const char *fmt, ...)
{
	va_list args;
	char tmp_log_buf[256];

	va_start(args, fmt);
	vscnprintf(tmp_log_buf, sizeof(tmp_log_buf), fmt, args);
	fdebug_log(bat_priv->debug_log, "[%10lu] %s",
		   (jiffies / HZ), tmp_log_buf);
	va_end(args);

	return 0;
}
Example #23
0
void pdc_printf(const char *fmt, ...)
{
	va_list args;
	char buf[1024];
	int i, len;

	va_start(args, fmt);
	len = vscnprintf(buf, sizeof(buf), fmt, args);
	va_end(args);

	for (i = 0; i < len; i++)
		pdc_iodc_outc(buf[i]);
}
Example #24
0
/**
 * batadv_debug_log() - Add debug log entry
 * @bat_priv: the bat priv with all the soft interface information
 * @fmt: format string
 *
 * Return: 0 on success or negative error number in case of failure
 */
int batadv_debug_log(struct batadv_priv *bat_priv, const char *fmt, ...)
{
	va_list args;
	char tmp_log_buf[256];

	va_start(args, fmt);
	vscnprintf(tmp_log_buf, sizeof(tmp_log_buf), fmt, args);
	batadv_fdebug_log(bat_priv->debug_log, "[%10u] %s",
			  jiffies_to_msecs(jiffies), tmp_log_buf);
	va_end(args);

	return 0;
}
Example #25
0
static void fiq_watchdog_printf(struct fiq_debugger_output *output,
				const char *fmt, ...)
{
	char buf[256];
	va_list ap;
	int len;

	va_start(ap, fmt);
	len = vscnprintf(buf, sizeof(buf), fmt, ap);
	va_end(ap);

	ramoops_console_write_buf(buf, len);
}
Example #26
0
void early_printk(const char *fmt, ...)
{
	char buf[512];
	int n;
	va_list ap;

	if (early_console_initialized) {
		va_start(ap, fmt);
		n = vscnprintf(buf, 512, fmt, ap);
		early_console->write(early_console, buf, n);
		va_end(ap);
	}
}
Example #27
0
File: console.c Project: RP7/misoc
int printf(const char *fmt, ...)
{
	va_list args;
	int len;
	char outbuf[256];

	va_start(args, fmt);
	len = vscnprintf(outbuf, sizeof(outbuf), fmt, args);
	va_end(args);
	outbuf[len] = 0;
	putsnonl(outbuf);

	return len;
}
Example #28
0
int telnet_printf(const char *fmt, ...)
{
	va_list args;
	int len;
	char outbuf[TELNET_PRINTF_BUFFER_SIZE];

	va_start(args, fmt);
	len = vscnprintf(outbuf, sizeof(outbuf), fmt, args);
	va_end(args);
	outbuf[len] = 0;
	telnet_putsnonl(outbuf);

	return len;
}
Example #29
0
/**
 * gpio_requestf() - [COMPAT] Request GPIO
 * @gpio:	GPIO number
 * @fmt:	Format string for the requested GPIO
 * @...:	Arguments for the printf() format string
 *
 * This function implements the API that's compatible with current
 * GPIO API used in U-Boot. The request is forwarded to particular
 * GPIO driver. Returns 0 on success, negative value on error.
 */
int gpio_requestf(unsigned gpio, const char *fmt, ...)
{
#if !defined(CONFIG_SPL_BUILD) || !defined(CONFIG_USE_TINY_PRINTF)
	va_list args;
	char buf[40];

	va_start(args, fmt);
	vscnprintf(buf, sizeof(buf), fmt, args);
	va_end(args);
	return gpio_request(gpio, buf);
#else
	return gpio_request(gpio, fmt);
#endif
}
Example #30
0
static int dm_gpio_requestf(struct gpio_desc *desc, const char *fmt, ...)
{
#if !defined(CONFIG_SPL_BUILD) || !defined(CONFIG_USE_TINY_PRINTF)
	va_list args;
	char buf[40];

	va_start(args, fmt);
	vscnprintf(buf, sizeof(buf), fmt, args);
	va_end(args);
	return dm_gpio_request(desc, buf);
#else
	return dm_gpio_request(desc, fmt);
#endif
}