Removed unneeded variables as warned by gcc 4.6

This commit is contained in:
Jean-Pierre André 2011-07-05 12:17:29 +02:00
parent 1c1c0540e8
commit 5cd49257b0
14 changed files with 23 additions and 72 deletions

View File

@ -38,10 +38,10 @@ static __inline__ void ntfs_debug_runlist_dump(const struct _runlist_element *rl
#define NTFS_BUG(msg) \
{ \
int ___i; \
int ___i = 1; \
ntfs_log_critical("Bug in %s(): %s\n", __FUNCTION__, msg); \
ntfs_log_debug("Forcing segmentation fault!"); \
___i = ((int*)NULL)[1]; \
___i = ((int*)NULL)[___i]; \
}
#endif /* defined _NTFS_DEBUG_H */

View File

@ -522,9 +522,7 @@ gid_t ntfs_find_group(const struct MAPPING* groupmapping, const SID * gsid)
{
gid_t gid;
const struct MAPPING *p;
int gsidsz;
gsidsz = ntfs_sid_size(gsid);
p = groupmapping;
while (p && p->xid && !ntfs_same_sid(gsid, p->sid))
p = p->next;
@ -1901,7 +1899,6 @@ static int buildacls_posix(struct MAPPING* const mapping[],
const SID *sid;
int acecnt;
int usidsz;
int gsidsz;
int wsidsz;
int asidsz;
int ssidsz;
@ -1909,7 +1906,6 @@ static int buildacls_posix(struct MAPPING* const mapping[],
le32 grants;
usidsz = ntfs_sid_size(usid);
gsidsz = ntfs_sid_size(gsid);
wsidsz = ntfs_sid_size(worldsid);
asidsz = ntfs_sid_size(adminsid);
ssidsz = ntfs_sid_size(systemsid);
@ -3132,7 +3128,6 @@ static int norm_ownadmin_permissions_posix(struct POSIX_SECURITY *posix_desc,
u16 tag;
u16 tagsset;
struct POSIX_ACE *pxace;
int acccnt;
mode_t denywrld;
mode_t allow;
mode_t deny;
@ -3141,7 +3136,6 @@ static int norm_ownadmin_permissions_posix(struct POSIX_SECURITY *posix_desc,
mode = 0;
pxace = posix_desc->acl.ace;
acccnt = posix_desc->acccnt;
tagsset = 0;
denywrld = 0;
/*
@ -3881,12 +3875,10 @@ struct POSIX_SECURITY *ntfs_build_permissions_posix(
int ntfs_build_permissions(const char *securattr,
const SID *usid, const SID *gsid, BOOL isdir)
{
const SECURITY_DESCRIPTOR_RELATIVE *phead;
int perm;
BOOL adminowns;
BOOL groupowns;
phead = (const SECURITY_DESCRIPTOR_RELATIVE*)securattr;
adminowns = ntfs_same_sid(usid,adminsid)
|| ntfs_same_sid(gsid,adminsid);
groupowns = !adminowns && ntfs_same_sid(gsid,usid);
@ -3969,7 +3961,6 @@ static struct MAPLIST *getmappingitem(FILEREADER reader, void *fileid,
{
int src;
int dst;
char *p;
char *q;
char *pu;
char *pg;
@ -4003,7 +3994,6 @@ static struct MAPLIST *getmappingitem(FILEREADER reader, void *fileid,
if (gotend) {
pu = pg = (char*)NULL;
/* decompose into uid, gid and sid */
p = item->maptext;
item->uidstr = item->maptext;
item->gidstr = strchr(item->uidstr, ':');
if (item->gidstr) {

View File

@ -1775,7 +1775,6 @@ s64 ntfs_attr_pwrite(ntfs_attr *na, const s64 pos, s64 count, const void *b)
} need_to = { 0, 0 };
BOOL wasnonresident = FALSE;
BOOL compressed;
BOOL sparse;
BOOL updatemap;
ntfs_log_enter("Entering for inode %lld, attr 0x%x, pos 0x%llx, count "
@ -1861,7 +1860,6 @@ s64 ntfs_attr_pwrite(ntfs_attr *na, const s64 pos, s64 count, const void *b)
!= const_cpu_to_le16(0);
need_to.undo_data_size = 1;
}
sparse = (na->data_flags & ATTR_IS_SPARSE) != const_cpu_to_le16(0);
/*
* For compressed data, a single full block was allocated
* to deal with compression, possibly in a previous call.
@ -2316,7 +2314,6 @@ int ntfs_attr_pclose(ntfs_attr *na)
ntfs_attr_search_ctx *ctx = NULL;
runlist_element *rl;
int eo;
s64 hole;
int compressed_part;
BOOL compressed;
@ -2428,7 +2425,6 @@ int ntfs_attr_pclose(ntfs_attr *na)
goto rl_err_out;
}
if (rl->lcn < (LCN)0) {
hole = rl->vcn + rl->length;
if (rl->lcn != (LCN)LCN_HOLE) {
errno = EIO;
ntfs_log_perror("%s: Unexpected LCN (%lld)",

View File

@ -376,7 +376,6 @@ int ntfs_invalidate_cache(struct CACHE_HEADER *cache,
int flags)
{
struct CACHED_GENERIC *current;
struct CACHED_GENERIC *previous;
struct CACHED_GENERIC *next;
struct HASH_ENTRY *link;
int count;
@ -412,7 +411,6 @@ int ntfs_invalidate_cache(struct CACHE_HEADER *cache,
* Search sequentially in LRU list
*/
current = cache->most_recent_entry;
previous = (struct CACHED_GENERIC*)NULL;
while (current) {
if (!compare(current, item)) {
next = current->next;
@ -423,7 +421,6 @@ int ntfs_invalidate_cache(struct CACHE_HEADER *cache,
current = next;
count++;
} else {
previous = current;
current = current->next;
}
}

View File

@ -257,7 +257,7 @@ u64 ntfs_inode_lookup_by_name(ntfs_inode *dir_ni,
u8 *index_end;
ntfs_attr *ia_na;
int eo, rc;
u32 index_block_size, index_vcn_size;
u32 index_block_size;
u8 index_vcn_size_bits;
ntfs_log_trace("Entering\n");
@ -378,10 +378,8 @@ u64 ntfs_inode_lookup_by_name(ntfs_inode *dir_ni,
/* Determine the size of a vcn in the directory index. */
if (vol->cluster_size <= index_block_size) {
index_vcn_size = vol->cluster_size;
index_vcn_size_bits = vol->cluster_size_bits;
} else {
index_vcn_size = vol->sector_size;
index_vcn_size_bits = vol->sector_size_bits;
}
@ -1039,7 +1037,7 @@ int ntfs_readdir(ntfs_inode *dir_ni, s64 *pos,
INDEX_ENTRY *ie;
INDEX_ALLOCATION *ia = NULL;
int rc, ir_pos, bmp_buf_size, bmp_buf_pos, eo;
u32 index_block_size, index_vcn_size;
u32 index_block_size;
u8 index_block_size_bits, index_vcn_size_bits;
ntfs_log_trace("Entering.\n");
@ -1131,10 +1129,8 @@ int ntfs_readdir(ntfs_inode *dir_ni, s64 *pos,
}
index_block_size_bits = ffs(index_block_size) - 1;
if (vol->cluster_size <= index_block_size) {
index_vcn_size = vol->cluster_size;
index_vcn_size_bits = vol->cluster_size_bits;
} else {
index_vcn_size = vol->sector_size;
index_vcn_size_bits = vol->sector_size_bits;
}
@ -2511,15 +2507,11 @@ int ntfs_set_ntfs_dos_name(ntfs_inode *ni, ntfs_inode *dir_ni,
char newname[MAX_DOS_NAME_LENGTH + 1];
ntfschar oldname[MAX_DOS_NAME_LENGTH];
int oldlen;
ntfs_volume *vol;
u64 fnum;
u64 dnum;
BOOL closed = FALSE;
ntfschar *shortname = NULL;
ntfschar longname[NTFS_MAX_NAME_LEN];
vol = ni->vol;
fnum = ni->mft_no;
/* convert the string to the NTFS wide chars */
if (size > MAX_DOS_NAME_LENGTH)
size = MAX_DOS_NAME_LENGTH;

View File

@ -139,7 +139,6 @@ static int fixup_loop(ntfs_inode *ni)
ntfs_attr *na;
ATTR_RECORD *a;
BOOL restart;
BOOL first;
int cnt;
int maxcnt;
int res = 0;
@ -200,7 +199,6 @@ static int fixup_loop(ntfs_inode *ni)
if (na)
ntfs_attr_close(na);
}
first = FALSE;
} while (restart && !res);
if (ctx)
ntfs_attr_put_search_ctx(ctx);

View File

@ -437,13 +437,12 @@ static int idata_cache_compare(const struct CACHED_GENERIC *cached,
void ntfs_inode_invalidate(ntfs_volume *vol, const MFT_REF mref)
{
struct CACHED_NIDATA item;
int count;
item.inum = MREF(mref);
item.ni = (ntfs_inode*)NULL;
item.pathname = (const char*)NULL;
item.varsize = 0;
count = ntfs_invalidate_cache(vol->nidata_cache,
ntfs_invalidate_cache(vol->nidata_cache,
GENERIC(&item),idata_cache_compare,CACHE_FREE);
}

View File

@ -468,7 +468,7 @@ BOOL ntfs_check_logfile(ntfs_attr *log_na, RESTART_PAGE_HEADER **rp)
u8 *kaddr = NULL;
RESTART_PAGE_HEADER *rstr1_ph = NULL;
RESTART_PAGE_HEADER *rstr2_ph = NULL;
int log_page_size, log_page_mask, err;
int log_page_size, err;
BOOL logfile_is_empty = TRUE;
u8 log_page_bits;
@ -481,7 +481,6 @@ BOOL ntfs_check_logfile(ntfs_attr *log_na, RESTART_PAGE_HEADER **rp)
if (size > (s64)MaxLogFileSize)
size = MaxLogFileSize;
log_page_size = DefaultLogPageSize;
log_page_mask = log_page_size - 1;
/*
* Use generic_ffs() instead of ffs() to enable the compiler to
* optimize log_page_size and log_page_bits into constants.

View File

@ -1190,7 +1190,7 @@ undo_alloc:
static int ntfs_mft_record_init(ntfs_volume *vol, s64 size)
{
int ret = -1;
ntfs_attr *mft_na, *mftbmp_na;
ntfs_attr *mft_na;
s64 old_data_initialized, old_data_size;
ntfs_attr_search_ctx *ctx;
@ -1199,7 +1199,6 @@ static int ntfs_mft_record_init(ntfs_volume *vol, s64 size)
/* NOTE: Caller must sanity check vol, vol->mft_na and vol->mftbmp_na */
mft_na = vol->mft_na;
mftbmp_na = vol->mftbmp_na;
/*
* The mft record is outside the initialized data. Extend the mft data
@ -1295,14 +1294,13 @@ undo_data_init:
static int ntfs_mft_rec_init(ntfs_volume *vol, s64 size)
{
int ret = -1;
ntfs_attr *mft_na, *mftbmp_na;
ntfs_attr *mft_na;
s64 old_data_initialized, old_data_size;
ntfs_attr_search_ctx *ctx;
ntfs_log_enter("Entering\n");
mft_na = vol->mft_na;
mftbmp_na = vol->mftbmp_na;
if (size > mft_na->allocated_size || size > mft_na->initialized_size) {
errno = EIO;

View File

@ -1623,7 +1623,7 @@ errno_set:
int ntfs_rl_truncate(runlist **arl, const VCN start_vcn)
{
runlist *rl;
BOOL is_end = FALSE;
/* BOOL is_end = FALSE; */
if (!arl || !*arl) {
errno = EINVAL;
@ -1666,8 +1666,10 @@ int ntfs_rl_truncate(runlist **arl, const VCN start_vcn)
*/
if (rl->length) {
++rl;
/*
if (!rl->length)
is_end = TRUE;
*/
rl->vcn = start_vcn;
rl->length = 0;
}

View File

@ -2013,7 +2013,6 @@ int ntfs_get_posix_acl(struct SECURITY_CONTEXT *scx, ntfs_inode *ni,
const SID *gsid; /* group of file/directory */
uid_t uid;
gid_t gid;
int perm;
BOOL isdir;
size_t outsize;
@ -2048,7 +2047,6 @@ int ntfs_get_posix_acl(struct SECURITY_CONTEXT *scx, ntfs_inode *ni,
* fetch owner and group for cacheing
*/
if (pxdesc) {
perm = pxdesc->mode & 07777;
/*
* Create a security id if there were none
* and upgrade option is selected
@ -2062,11 +2060,10 @@ int ntfs_get_posix_acl(struct SECURITY_CONTEXT *scx, ntfs_inode *ni,
#if OWNERFROMACL
uid = ntfs_find_user(scx->mapping[MAPUSERS],usid);
#else
if (!perm && ntfs_same_sid(usid, adminsid)) {
if (!(pxdesc->mode & 07777)
&& ntfs_same_sid(usid, adminsid)) {
uid = find_tenant(scx,
securattr);
if (uid)
perm = 0700;
} else
uid = ntfs_find_user(scx->mapping[MAPUSERS],usid);
#endif
@ -2893,7 +2890,6 @@ int ntfs_set_posix_acl(struct SECURITY_CONTEXT *scx, ntfs_inode *ni,
uid_t uid;
uid_t gid;
int res;
mode_t mode;
BOOL isdir;
BOOL deflt;
BOOL exist;
@ -2919,7 +2915,6 @@ int ntfs_set_posix_acl(struct SECURITY_CONTEXT *scx, ntfs_inode *ni,
gid = cached->gid;
oldpxdesc = cached->pxdesc;
if (oldpxdesc) {
mode = oldpxdesc->mode;
newpxdesc = ntfs_replace_acl(oldpxdesc,
(const struct POSIX_ACL*)value,count,deflt);
}
@ -2946,7 +2941,6 @@ int ntfs_set_posix_acl(struct SECURITY_CONTEXT *scx, ntfs_inode *ni,
|| (!exist && (flags & XATTR_REPLACE))) {
errno = (exist ? EEXIST : ENODATA);
} else {
mode = oldpxdesc->mode;
newpxdesc = ntfs_replace_acl(oldpxdesc,
(const struct POSIX_ACL*)value,count,deflt);
}

View File

@ -393,11 +393,9 @@ int main(int argc, char *argv[])
char *filename;
ntfs_inode *dir_ni;
ntfs_inode *ni;
int dest_path_len;
char *dirname_last_whack;
filename = basename(opts.dest_file);
dest_path_len = strlen(opts.dest_file);
parent_dirname = strdup(opts.dest_file);
if (!parent_dirname) {
ntfs_log_perror("strdup() failed");

View File

@ -115,7 +115,6 @@ static long nr_entries; /* Number of range entries */
static int parse_inode_arg(void)
{
int p;
u32 imax;
u32 range_begin;
u32 range_end;
u32 range_temp;
@ -132,7 +131,6 @@ static int parse_inode_arg(void)
/* init variables */
p = strlen(optarg);
imax = p;
opt_arg_ptr = optarg;
opt_arg_end1 = optarg;
opt_arg_end2 = &(optarg[p]);
@ -1279,7 +1277,6 @@ static int calc_percentage(struct ufile *file, ntfs_volume *vol)
static void dump_record(struct ufile *file)
{
char buffer[20];
const char *name;
struct list_head *item;
int i;
@ -1297,11 +1294,6 @@ static void dump_record(struct ufile *file)
list_for_each(item, &file->name) {
struct filename *f = list_entry(item, struct filename, list);
if (f->name)
name = f->name;
else
name = NONE;
ntfs_log_quiet("Filename: (%d) %s\n", f->name_space, f->name);
ntfs_log_quiet("File Flags: ");
if (f->flags & FILE_ATTR_SYSTEM)

View File

@ -184,6 +184,9 @@
*
* Apr 2011, version 1.3.20
* - fixed false memory leak detection
*
* Jun 2011, version 1.3.21
* - cleaned a few unneeded variables
*/
/*
@ -207,7 +210,7 @@
* General parameters which may have to be adapted to needs
*/
#define AUDT_VERSION "1.3.20"
#define AUDT_VERSION "1.3.21"
#define GET_FILE_SECURITY "ntfs_get_file_security"
#define SET_FILE_SECURITY "ntfs_set_file_security"
@ -2024,14 +2027,15 @@ int linux_permissions(const char *attr, BOOL isdir)
uid_t linux_owner(const char *attr)
{
const SECURITY_DESCRIPTOR_RELATIVE *phead;
const SID *usid;
uid_t uid;
phead = (const SECURITY_DESCRIPTOR_RELATIVE*)attr;
#if OWNERFROMACL
usid = ntfs_acl_owner((const char*)attr);
#else
const SECURITY_DESCRIPTOR_RELATIVE *phead;
phead = (const SECURITY_DESCRIPTOR_RELATIVE*)attr;
usid = (const SID*)&attr[le32_to_cpu(phead->owner)];
#endif
#if defined(WIN32) | defined(STSC)
@ -2400,7 +2404,6 @@ void showhex(FILE *fd)
int lth;
int first;
unsigned int pos;
unsigned char b;
u32 v;
int c;
int isdir;
@ -2410,7 +2413,6 @@ void showhex(FILE *fd)
BOOL isdump;
BOOL done;
b = 0;
pos = 0;
off = 0;
done = FALSE;
@ -2491,7 +2493,6 @@ void showhex(FILE *fd)
BOOL applyattr(const char *fullname, const char *attr,
BOOL withattr, int attrib, s32 key)
{
const SECURITY_DESCRIPTOR_RELATIVE *phead;
struct SECURITY_DATA *psecurdata;
const char *curattr;
char *newattr;
@ -2549,7 +2550,6 @@ BOOL applyattr(const char *fullname, const char *attr,
if (curattr) {
phead = (const SECURITY_DESCRIPTOR_RELATIVE*)curattr;
#ifdef WIN32
/* SACL currently not set, need some special privilege */
selection = OWNER_SECURITY_INFORMATION
@ -2617,8 +2617,6 @@ BOOL restore(FILE *fd)
int lth;
int first;
unsigned int pos;
unsigned int size;
unsigned char b;
int c;
int isdir;
int mode;
@ -2633,9 +2631,7 @@ BOOL restore(FILE *fd)
BOOL withattr;
BOOL done;
b = 0;
pos = 0;
size = 0;
off = 0;
done = FALSE;
withattr = FALSE;
@ -2680,7 +2676,6 @@ BOOL restore(FILE *fd)
mode = linux_permissions(attr,isdir);
printf("Interpreted Unix mode 0%03o\n",mode);
}
size = pos;
pos = 0;
}
if (isdump && !off)
@ -7096,13 +7091,14 @@ char *argv[];
int main(int argc, char *argv[])
{
FILE *fd;
unsigned int mode;
const char *p;
int xarg;
BOOL cmderr;
int i;
#if POSIXACLS
struct POSIX_SECURITY *pxdesc;
#else
unsigned int mode;
#endif
printf("%s\n",BANNER);
@ -7171,7 +7167,6 @@ int main(int argc, char *argv[])
cmderr = listfiles(argv[xarg],argv[xarg+1]);
break;
case 3 :
mode = 0;
p = argv[xarg+1];
#if POSIXACLS
pxdesc = encode_posix_acl(p);
@ -7202,6 +7197,7 @@ int main(int argc, char *argv[])
} else
cmderr = TRUE;
#else
mode = 0;
while ((*p >= '0') && (*p <= '7'))
mode = (mode << 3) + (*p++) - '0';
if (*p) {