Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
qemu
提交
42dfb095
Q
qemu
项目概览
openeuler
/
qemu
通知
10
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Q
qemu
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
42dfb095
编写于
11月 02, 2011
作者:
A
Anthony Liguori
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'aneesh/for-upstream-8' into staging
上级
0e9a2ea2
779b5b04
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
4 addition
and
99 deletion
+4
-99
hw/9pfs/virtio-9p.c
hw/9pfs/virtio-9p.c
+4
-99
未找到文件。
hw/9pfs/virtio-9p.c
浏览文件 @
42dfb095
...
...
@@ -11,6 +11,9 @@
*
*/
#include <glib.h>
#include <glib/gprintf.h>
#include "hw/virtio.h"
#include "hw/pc.h"
#include "qemu_socket.h"
...
...
@@ -161,114 +164,16 @@ void v9fs_string_null(V9fsString *str)
v9fs_string_free
(
str
);
}
static
int
number_to_string
(
void
*
arg
,
char
type
)
{
unsigned
int
ret
=
0
;
switch
(
type
)
{
case
'u'
:
{
unsigned
int
num
=
*
(
unsigned
int
*
)
arg
;
do
{
ret
++
;
num
=
num
/
10
;
}
while
(
num
);
break
;
}
case
'U'
:
{
unsigned
long
num
=
*
(
unsigned
long
*
)
arg
;
do
{
ret
++
;
num
=
num
/
10
;
}
while
(
num
);
break
;
}
default:
printf
(
"Number_to_string: Unknown number format
\n
"
);
return
-
1
;
}
return
ret
;
}
static
int
GCC_FMT_ATTR
(
2
,
0
)
v9fs_string_alloc_printf
(
char
**
strp
,
const
char
*
fmt
,
va_list
ap
)
{
va_list
ap2
;
char
*
iter
=
(
char
*
)
fmt
;
int
len
=
0
;
int
nr_args
=
0
;
char
*
arg_char_ptr
;
unsigned
int
arg_uint
;
unsigned
long
arg_ulong
;
/* Find the number of %'s that denotes an argument */
for
(
iter
=
strstr
(
iter
,
"%"
);
iter
;
iter
=
strstr
(
iter
,
"%"
))
{
nr_args
++
;
iter
++
;
}
len
=
strlen
(
fmt
)
-
2
*
nr_args
;
if
(
!
nr_args
)
{
goto
alloc_print
;
}
va_copy
(
ap2
,
ap
);
iter
=
(
char
*
)
fmt
;
/* Now parse the format string */
for
(
iter
=
strstr
(
iter
,
"%"
);
iter
;
iter
=
strstr
(
iter
,
"%"
))
{
iter
++
;
switch
(
*
iter
)
{
case
'u'
:
arg_uint
=
va_arg
(
ap2
,
unsigned
int
);
len
+=
number_to_string
((
void
*
)
&
arg_uint
,
'u'
);
break
;
case
'l'
:
if
(
*++
iter
==
'u'
)
{
arg_ulong
=
va_arg
(
ap2
,
unsigned
long
);
len
+=
number_to_string
((
void
*
)
&
arg_ulong
,
'U'
);
}
else
{
return
-
1
;
}
break
;
case
's'
:
arg_char_ptr
=
va_arg
(
ap2
,
char
*
);
len
+=
strlen
(
arg_char_ptr
);
break
;
case
'c'
:
len
+=
1
;
break
;
default:
fprintf
(
stderr
,
"v9fs_string_alloc_printf:Incorrect format %c"
,
*
iter
);
return
-
1
;
}
iter
++
;
}
alloc_print:
*
strp
=
g_malloc
((
len
+
1
)
*
sizeof
(
**
strp
));
return
vsprintf
(
*
strp
,
fmt
,
ap
);
}
void
GCC_FMT_ATTR
(
2
,
3
)
v9fs_string_sprintf
(
V9fsString
*
str
,
const
char
*
fmt
,
...)
{
va_list
ap
;
int
err
;
v9fs_string_free
(
str
);
va_start
(
ap
,
fmt
);
err
=
v9fs_string_alloc_printf
(
&
str
->
data
,
fmt
,
ap
);
BUG_ON
(
err
==
-
1
);
str
->
size
=
g_vasprintf
(
&
str
->
data
,
fmt
,
ap
);
va_end
(
ap
);
str
->
size
=
err
;
}
void
v9fs_string_copy
(
V9fsString
*
lhs
,
V9fsString
*
rhs
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录