xref: /illumos-gate/usr/src/uts/common/io/qede/qede_misc.c (revision 14b24e2b79293068c8e016a69ef1d872fb5e2fd5)
1*14b24e2bSVaishali Kulkarni /*
2*14b24e2bSVaishali Kulkarni  * This file and its contents are supplied under the terms of the
3*14b24e2bSVaishali Kulkarni  * Common Development and Distribution License ("CDDL"), version 1.0.
4*14b24e2bSVaishali Kulkarni  * You may only use this file in accordance with the terms of version
5*14b24e2bSVaishali Kulkarni  * 1.0 of the CDDL.
6*14b24e2bSVaishali Kulkarni  *
7*14b24e2bSVaishali Kulkarni  * A full copy of the text of the CDDL should have accompanied this
8*14b24e2bSVaishali Kulkarni  * source.  A copy of the CDDL is also available via the Internet at
9*14b24e2bSVaishali Kulkarni  * http://www.illumos.org/license/CDDL.
10*14b24e2bSVaishali Kulkarni  */
11*14b24e2bSVaishali Kulkarni 
12*14b24e2bSVaishali Kulkarni /*
13*14b24e2bSVaishali Kulkarni  * Copyright (c) 2017, Joyent, Inc.
14*14b24e2bSVaishali Kulkarni  */
15*14b24e2bSVaishali Kulkarni 
16*14b24e2bSVaishali Kulkarni /*
17*14b24e2bSVaishali Kulkarni  * Misc. support routines
18*14b24e2bSVaishali Kulkarni  */
19*14b24e2bSVaishali Kulkarni 
20*14b24e2bSVaishali Kulkarni #include <sys/cmn_err.h>
21*14b24e2bSVaishali Kulkarni #include <sys/ddi.h>
22*14b24e2bSVaishali Kulkarni #include <sys/sunddi.h>
23*14b24e2bSVaishali Kulkarni 
24*14b24e2bSVaishali Kulkarni /*
25*14b24e2bSVaishali Kulkarni  * We need to emulate sprintf. Unfortunately illumos sprintf does not return the
26*14b24e2bSVaishali Kulkarni  * number of bytes written, only a pointer to the string. Therefore we need this
27*14b24e2bSVaishali Kulkarni  * wrapper.
28*14b24e2bSVaishali Kulkarni  */
29*14b24e2bSVaishali Kulkarni size_t
qede_sprintf(char * s,const char * fmt,...)30*14b24e2bSVaishali Kulkarni qede_sprintf(char *s, const char *fmt, ...)
31*14b24e2bSVaishali Kulkarni {
32*14b24e2bSVaishali Kulkarni 	size_t r;
33*14b24e2bSVaishali Kulkarni 	va_list args;
34*14b24e2bSVaishali Kulkarni 
35*14b24e2bSVaishali Kulkarni 	va_start(args, fmt);
36*14b24e2bSVaishali Kulkarni 	r = vsnprintf(s, SIZE_MAX, fmt, args);
37*14b24e2bSVaishali Kulkarni 	va_end(args);
38*14b24e2bSVaishali Kulkarni 
39*14b24e2bSVaishali Kulkarni 	return (r);
40*14b24e2bSVaishali Kulkarni }
41