correct use of uninitialised variable

This commit is contained in:
Dave Murphy 2010-10-07 21:53:18 +00:00
parent 571d57ee0a
commit 81110882db

View File

@ -654,10 +654,9 @@ ssize_t _FAT_write_r (struct _reent *r, int fd, const char *ptr, size_t len) {
_FAT_lock(&partition->lock); _FAT_lock(&partition->lock);
// Only write up to the maximum file size, taking into account wrap-around of ints // Only write up to the maximum file size, taking into account wrap-around of ints
if (remain + file->filesize > FILE_MAX_SIZE || len + file->filesize < file->filesize) { if (len + file->filesize > FILE_MAX_SIZE || len + file->filesize < file->filesize) {
len = FILE_MAX_SIZE - file->filesize; len = FILE_MAX_SIZE - file->filesize;
} }
remain = len;
// Short circuit cases where len is 0 (or less) // Short circuit cases where len is 0 (or less)
if (len <= 0) { if (len <= 0) {
@ -665,6 +664,8 @@ ssize_t _FAT_write_r (struct _reent *r, int fd, const char *ptr, size_t len) {
return 0; return 0;
} }
remain = len;
// Get a new cluster for the start of the file if required // Get a new cluster for the start of the file if required
if (file->startCluster == CLUSTER_FREE) { if (file->startCluster == CLUSTER_FREE) {
tempNextCluster = _FAT_fat_linkFreeCluster (partition, CLUSTER_FREE); tempNextCluster = _FAT_fat_linkFreeCluster (partition, CLUSTER_FREE);