]> git.ipfire.org Git - thirdparty/libvirt.git/commit
storage: use simpler 'char *'
authorEric Blake <eblake@redhat.com>
Tue, 5 Nov 2013 17:44:14 +0000 (10:44 -0700)
committerEric Blake <eblake@redhat.com>
Wed, 6 Nov 2013 22:41:12 +0000 (15:41 -0700)
commit5717ee6ab871253c3e512ece7d59b754624e99c0
tree5c1a219bb2ddc834090bd45ff986b69a560ce00c
parent3897975eeae8582021017e7d61484d32410e8d40
storage: use simpler 'char *'

'unsigned char *' makes sense if you are doing math on bytes and
don't want to worry about wraparound from a signed 'char'; but
since all we are doing is memcmp() or virReadBufInt*[LB]E(), which
are both safe on either type of char, and since read() prefers to
operate on 'char *', it's simpler to avoid casts by just typing
things as 'char *' from the get-go.  [Technically, read can
operate on an 'unsigned char *' thanks to the C rule that any
pointer can be implicitly converted to 'char *' for legacy K&R
compatibility; but where this patch saves us is if we try to use
virfile.h functions that take 'char **' in order to allocate the
buffer, where the compiler would barf on type mismatch.]

* src/util/virstoragefile.c (FileTypeInfo): Avoid unsigned char.
(cowGetBackingStore, qcow2GetBackingStoreFormat)
(qcowXGetBackingStore, qcow1GetBackingStore)
(qcow2GetBackingStore, vmdk4GetBackingStore, qedGetBackingStore)
(virStorageFileMatchesMagic, virStorageFileMatchesVersion)
(virStorageFileProbeFormatFromBuf, qcow2GetFeatures)
(virStorageFileGetMetadataInternal)
(virStorageFileProbeFormatFromFD): Simplify clients.

Signed-off-by: Eric Blake <eblake@redhat.com>
src/util/virstoragefile.c