9p: v9fs_path_copy() readability
lhs/rhs doesn't tell much about how argument are handled, dst/src is and const arguments is clearer in my mind. Use g_memdup() while at it. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Greg Kurz <groug@kaod.org>
This commit is contained in:
parent
299a2e6fac
commit
e446a1eb5e
|
@ -190,12 +190,11 @@ v9fs_path_sprintf(V9fsPath *path, const char *fmt, ...)
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void v9fs_path_copy(V9fsPath *lhs, V9fsPath *rhs)
|
void v9fs_path_copy(V9fsPath *dst, const V9fsPath *src)
|
||||||
{
|
{
|
||||||
v9fs_path_free(lhs);
|
v9fs_path_free(dst);
|
||||||
lhs->data = g_malloc(rhs->size);
|
dst->size = src->size;
|
||||||
memcpy(lhs->data, rhs->data, rhs->size);
|
dst->data = g_memdup(src->data, src->size);
|
||||||
lhs->size = rhs->size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int v9fs_name_to_path(V9fsState *s, V9fsPath *dirpath,
|
int v9fs_name_to_path(V9fsState *s, V9fsPath *dirpath,
|
||||||
|
|
|
@ -343,7 +343,7 @@ void coroutine_fn v9fs_reclaim_fd(V9fsPDU *pdu);
|
||||||
void v9fs_path_init(V9fsPath *path);
|
void v9fs_path_init(V9fsPath *path);
|
||||||
void v9fs_path_free(V9fsPath *path);
|
void v9fs_path_free(V9fsPath *path);
|
||||||
void v9fs_path_sprintf(V9fsPath *path, const char *fmt, ...);
|
void v9fs_path_sprintf(V9fsPath *path, const char *fmt, ...);
|
||||||
void v9fs_path_copy(V9fsPath *lhs, V9fsPath *rhs);
|
void v9fs_path_copy(V9fsPath *dst, const V9fsPath *src);
|
||||||
int v9fs_name_to_path(V9fsState *s, V9fsPath *dirpath,
|
int v9fs_name_to_path(V9fsState *s, V9fsPath *dirpath,
|
||||||
const char *name, V9fsPath *path);
|
const char *name, V9fsPath *path);
|
||||||
int v9fs_device_realize_common(V9fsState *s, const V9fsTransport *t,
|
int v9fs_device_realize_common(V9fsState *s, const V9fsTransport *t,
|
||||||
|
|
Loading…
Reference in New Issue