simplify and avoid pointer gymnastics

This commit is contained in:
christos 2011-02-24 23:49:26 +00:00
parent aa30cd0dfb
commit b6ccfb3a6f
1 changed files with 5 additions and 8 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: libhfs.c,v 1.9 2009/11/27 15:58:39 pooka Exp $ */ /* $NetBSD: libhfs.c,v 1.10 2011/02/24 23:49:26 christos Exp $ */
/*- /*-
* Copyright (c) 2005, 2007 The NetBSD Foundation, Inc. * Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
@ -47,7 +47,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: libhfs.c,v 1.9 2009/11/27 15:58:39 pooka Exp $"); __KERNEL_RCSID(0, "$NetBSD: libhfs.c,v 1.10 2011/02/24 23:49:26 christos Exp $");
#include "libhfs.h" #include "libhfs.h"
@ -460,14 +460,11 @@ hfslib_path_to_cnid(hfs_volume* in_vol,
goto exit; goto exit;
/* copy only the bytes that are actually used */ /* copy only the bytes that are actually used */
memcpy(*out_unicode+2, path + path_offset, total_path_length*2); memcpy(*out_unicode + 2, path + path_offset, total_path_length*2);
/* insert forward slash at start */ /* insert forward slash at start */
(*out_unicode)[0] = 0x00; uchar = be16toh(0x2F);
(*out_unicode)[1] = 0x2F; memcpy(*out_unicode, &uchar, sizeof(uchar));
ptr = (uint16_t*)*out_unicode;
uchar = be16tohp((void*)&ptr);
*(ptr-1) = uchar;
/* insert null char at end */ /* insert null char at end */
(*out_unicode)[total_path_length*2+2] = 0x00; (*out_unicode)[total_path_length*2+2] = 0x00;