Windows: read and write take void* buffers, open takes a const char*

nt_read and nt_write were defined to take a char* buffer which was
then cast to a void *.  Meantime every call of OS_READ and
OS_WRITE were casting to a char*.

Equally every call of OS_OPEN was passing down a const char*,
causing warnings.

This checkin fixes this:
 nt_read : char* to void*
 nt_write: char* to const void*
 nt_open char*  to const char*

Change-Id: Id4e138b9d347e1a9f35241e162a105d5f462b168
Reviewed-on: http://gerrit.openafs.org/3744
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
This commit is contained in:
Rod Widdowson 2011-01-23 10:59:28 +00:00 committed by Jeffrey Altman
parent 42c5806599
commit 6d2636b886
3 changed files with 10 additions and 10 deletions

View File

@ -2742,7 +2742,7 @@ convertVolumeInfo(FD_t fdr, FD_t fdw, afs_uint32 vid)
struct VolumeDiskData vd; struct VolumeDiskData vd;
char *p; char *p;
if (OS_READ(fdr, (char *)&vd, sizeof(struct VolumeDiskData)) != if (OS_READ(fdr, &vd, sizeof(struct VolumeDiskData)) !=
sizeof(struct VolumeDiskData)) { sizeof(struct VolumeDiskData)) {
Log("1 convertVolumeInfo: read failed for %lu with code %d\n", Log("1 convertVolumeInfo: read failed for %lu with code %d\n",
afs_printable_uint32_lu(vid), afs_printable_uint32_lu(vid),
@ -2761,7 +2761,7 @@ convertVolumeInfo(FD_t fdr, FD_t fdw, afs_uint32 vid)
if (p && !strcmp(p, ".readonly")) { if (p && !strcmp(p, ".readonly")) {
memset(p, 0, 9); memset(p, 0, 9);
} }
if (OS_WRITE(fdw, (char *)&vd, sizeof(struct VolumeDiskData)) != if (OS_WRITE(fdw, &vd, sizeof(struct VolumeDiskData)) !=
sizeof(struct VolumeDiskData)) { sizeof(struct VolumeDiskData)) {
Log("1 convertVolumeInfo: write failed for %lu with code %d\n", Log("1 convertVolumeInfo: write failed for %lu with code %d\n",
afs_printable_uint32_lu(vid), afs_printable_uint32_lu(vid),

View File

@ -76,7 +76,7 @@ nt_unlink(char *name)
* the handle or -1 on error. * the handle or -1 on error.
*/ */
FD_t FD_t
nt_open(char *name, int flags, int mode) nt_open(const char *name, int flags, int mode)
{ {
HANDLE fh; HANDLE fh;
DWORD nt_access = 0; DWORD nt_access = 0;
@ -141,12 +141,12 @@ nt_close(FD_t fd)
} }
int int
nt_write(FD_t fd, char *buf, afs_sfsize_t size) nt_write(FD_t fd, void *buf, afs_sfsize_t size)
{ {
BOOL code; BOOL code;
DWORD nbytes; DWORD nbytes;
code = WriteFile((HANDLE) fd, (void *)buf, (DWORD) size, &nbytes, NULL); code = WriteFile((HANDLE) fd, buf, (DWORD) size, &nbytes, NULL);
if (!code) { if (!code) {
errno = nterr_nt2unix(GetLastError(), EBADF); errno = nterr_nt2unix(GetLastError(), EBADF);
@ -181,12 +181,12 @@ nt_pwrite(FD_t fd, const void * buf, afs_sfsize_t count, afs_foff_t offset)
} }
int int
nt_read(FD_t fd, char *buf, afs_sfsize_t size) nt_read(FD_t fd, void *buf, afs_sfsize_t size)
{ {
BOOL code; BOOL code;
DWORD nbytes; DWORD nbytes;
code = ReadFile((HANDLE) fd, (void *)buf, (DWORD) size, &nbytes, NULL); code = ReadFile((HANDLE) fd, buf, (DWORD) size, &nbytes, NULL);
if (!code) { if (!code) {
DWORD gle = GetLastError(); DWORD gle = GetLastError();

View File

@ -22,10 +22,10 @@ extern char *PrintInode(char *, Inode);
#endif #endif
/* Basic file operations */ /* Basic file operations */
extern FD_t nt_open(char *name, int flags, int mode); extern FD_t nt_open(const char *name, int flags, int mode);
extern int nt_close(FD_t fd); extern int nt_close(FD_t fd);
extern int nt_write(FD_t fd, char *buf, afs_sfsize_t size); extern int nt_write(FD_t fd, void *buf, afs_sfsize_t size);
extern int nt_read(FD_t fd, char *buf, afs_sfsize_t size); extern int nt_read(FD_t fd, void *buf, afs_sfsize_t size);
extern int nt_pread(FD_t fd, void * buf, afs_sfsize_t count, afs_foff_t offset); extern int nt_pread(FD_t fd, void * buf, afs_sfsize_t count, afs_foff_t offset);
extern int nt_pwrite(FD_t fd, const void * buf, afs_sfsize_t count, afs_foff_t offset); extern int nt_pwrite(FD_t fd, const void * buf, afs_sfsize_t count, afs_foff_t offset);
extern afs_sfsize_t nt_size(FD_t fd); extern afs_sfsize_t nt_size(FD_t fd);