libquota: quiet log_err() bad format warnings

The macro for log_err() was written so that it needed to always
have an argument, but GCC was unhappy to have an argument when
none was specified in the format string.  Use the CPP "##" to
eat the preceeding comma if no argument is specified.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
debian-1.42.9
Andreas Dilger 2012-11-29 05:47:54 -07:00 committed by Theodore Ts'o
parent 00eb0eee0a
commit 0ce0172984
5 changed files with 32 additions and 31 deletions

View File

@ -13,14 +13,14 @@
# endif
#endif
#define log_err(format, ...) fprintf(stderr, \
"[ERROR] %s:%d:%s:: " format "\n", \
__FILE__, __LINE__, __func__, __VA_ARGS__)
#define log_err(format, arg ...) \
fprintf(stderr, "[ERROR] %s:%d:%s:: " format "\n", \
__FILE__, __LINE__, __func__, ## arg)
#ifdef DEBUG_QUOTA
# define log_debug(format, ...) fprintf(stderr, \
"[DEBUG] %s:%d:%s:: " format "\n", \
__FILE__, __LINE__, __func__, __VA_ARGS__)
# define log_debug(format, arg ...) \
fprintf(stderr, "[DEBUG] %s:%d:%s:: " format "\n", \
__FILE__, __LINE__, __func__, ## arg)
#else
# define log_debug(format, ...)
#endif

View File

@ -132,7 +132,7 @@ errcode_t quota_write_inode(quota_ctx_t qctx, int qtype)
fs = qctx->fs;
retval = ext2fs_get_mem(sizeof(struct quota_handle), &h);
if (retval) {
log_err("Unable to allocate quota handle", "");
log_err("Unable to allocate quota handle");
goto out;
}
@ -148,7 +148,7 @@ errcode_t quota_write_inode(quota_ctx_t qctx, int qtype)
retval = quota_file_create(h, fs, i, fmt);
if (retval < 0) {
log_err("Cannot initialize io on quotafile", "");
log_err("Cannot initialize io on quotafile");
continue;
}
@ -218,7 +218,7 @@ errcode_t quota_init_context(quota_ctx_t *qctx, ext2_filsys fs, int qtype)
err = ext2fs_get_mem(sizeof(struct quota_ctx), &ctx);
if (err) {
log_err("Failed to allocate quota context", "");
log_err("Failed to allocate quota context");
return err;
}
@ -228,7 +228,7 @@ errcode_t quota_init_context(quota_ctx_t *qctx, ext2_filsys fs, int qtype)
continue;
err = ext2fs_get_mem(sizeof(dict_t), &dict);
if (err) {
log_err("Failed to allocate dictionary", "");
log_err("Failed to allocate dictionary");
return err;
}
ctx->quota_dict[i] = dict;
@ -273,7 +273,7 @@ static struct dquot *get_dq(dict_t *dict, __u32 key)
dq = dnode_get(n);
else {
if (ext2fs_get_mem(sizeof(struct dquot), &dq)) {
log_err("Unable to allocate dquot", "");
log_err("Unable to allocate dquot");
return NULL;
}
memset(dq, 0, sizeof(struct dquot));
@ -425,9 +425,10 @@ static int scan_dquots_callback(struct dquot *dquot, void *cb_data)
scan_data->usage_is_inconsistent = 1;
fprintf(stderr, "[QUOTA WARNING] Usage inconsistent for ID %d:"
"actual (%llu, %llu) != expected (%llu, %llu)\n",
dq->dq_id, dq->dq_dqb.dqb_curspace,
dq->dq_dqb.dqb_curinodes, dquot->dq_dqb.dqb_curspace,
dquot->dq_dqb.dqb_curinodes);
dq->dq_id, (long long)dq->dq_dqb.dqb_curspace,
(long long)dq->dq_dqb.dqb_curinodes,
(long long)dquot->dq_dqb.dqb_curspace,
(long long)dquot->dq_dqb.dqb_curinodes);
}
if (scan_data->update_limits) {
@ -463,6 +464,7 @@ static errcode_t quota_read_all_dquots(struct quota_handle *qh,
/*
* Write all memory dquots into quota file
*/
#if 0 /* currently unused, but may be useful in the future? */
static errcode_t quota_write_all_dquots(struct quota_handle *qh,
quota_ctx_t qctx)
{
@ -477,6 +479,7 @@ static errcode_t quota_write_all_dquots(struct quota_handle *qh,
ext2fs_write_bitmaps(qctx->fs);
return 0;
}
#endif
/*
* Updates the in-memory quota limits from the given quota inode.
@ -491,13 +494,13 @@ errcode_t quota_update_limits(quota_ctx_t qctx, ext2_ino_t qf_ino, int type)
err = ext2fs_get_mem(sizeof(struct quota_handle), &qh);
if (err) {
log_err("Unable to allocate quota handle", "");
log_err("Unable to allocate quota handle");
return err;
}
err = quota_file_open(qh, qctx->fs, qf_ino, type, -1, 0);
if (err) {
log_err("Open quota file failed", "");
log_err("Open quota file failed");
goto out;
}
@ -536,7 +539,7 @@ errcode_t quota_compare_and_update(quota_ctx_t qctx, int qtype,
fs->super->s_grp_quota_inum;
err = quota_file_open(&qh, fs, qf_ino, qtype, -1, 0);
if (err) {
log_err("Open quota file failed", "");
log_err("Open quota file failed");
goto out;
}
@ -546,7 +549,7 @@ errcode_t quota_compare_and_update(quota_ctx_t qctx, int qtype,
scan_data.usage_is_inconsistent = 0;
err = qh.qh_ops->scan_dquots(&qh, scan_dquots_callback, &scan_data);
if (err) {
log_err("Error scanning dquots", "");
log_err("Error scanning dquots");
goto out;
}
*usage_inconsistent = scan_data.usage_is_inconsistent;

View File

@ -243,13 +243,13 @@ errcode_t quota_file_open(struct quota_handle *h, ext2_filsys fs,
if (h->qh_ops->check_file &&
(h->qh_ops->check_file(h, type, fmt) == 0)) {
log_err("qh_ops->check_file failed", "");
log_err("qh_ops->check_file failed");
ext2fs_file_close(e2_file);
return -1;
}
if (h->qh_ops->init_io && (h->qh_ops->init_io(h) < 0)) {
log_err("qh_ops->init_io failed", "");
log_err("qh_ops->init_io failed");
ext2fs_file_close(e2_file);
return -1;
}
@ -264,7 +264,7 @@ static errcode_t quota_inode_init_new(ext2_filsys fs, ext2_ino_t ino)
err = ext2fs_read_inode(fs, ino, &inode);
if (err) {
log_err("ex2fs_read_inode failed", "");
log_err("ex2fs_read_inode failed");
return err;
}
@ -316,7 +316,7 @@ errcode_t quota_file_create(struct quota_handle *h, ext2_filsys fs, int type, in
err = quota_inode_init_new(fs, qf_inum);
if (err) {
log_err("init_new_quota_inode failed", "");
log_err("init_new_quota_inode failed");
goto out_err;
}
h->qh_qf.ino = qf_inum;
@ -339,7 +339,7 @@ errcode_t quota_file_create(struct quota_handle *h, ext2_filsys fs, int type, in
h->qh_ops = &quotafile_ops_2;
if (h->qh_ops->new_io && (h->qh_ops->new_io(h) < 0)) {
log_err("qh_ops->new_io failed", "");
log_err("qh_ops->new_io failed");
goto out_err1;
}
@ -386,7 +386,7 @@ struct dquot *get_empty_dquot(void)
struct dquot *dquot;
if (ext2fs_get_memzero(sizeof(struct dquot), &dquot)) {
log_err("Failed to allocate dquot", "");
log_err("Failed to allocate dquot");
return NULL;
}

View File

@ -24,7 +24,7 @@ static inline dqbuf_t getdqbuf(void)
{
dqbuf_t buf;
if (ext2fs_get_memzero(QT_BLKSIZE, &buf)) {
log_err("Failed to allocate dqbuf", "");
log_err("Failed to allocate dqbuf");
return NULL;
}
@ -101,7 +101,7 @@ static int get_free_dqblk(struct quota_handle *h)
if (write_blk(h, info->dqi_blocks, buf) < 0) {
freedqbuf(buf);
log_err("Cannot allocate new quota block "
"(out of disk space).", "");
"(out of disk space).");
return -ENOSPC;
}
blk = info->dqi_blocks++;
@ -230,8 +230,7 @@ static uint find_free_dqentry(struct quota_handle *h, struct dquot *dquot,
ddquot += info->dqi_entry_size;
if (i == qtree_dqstr_in_blk(info))
log_err("find_free_dqentry(): Data block full but it "
"shouldn't.", "");
log_err("find_free_dqentry(): Data block full unexpectedly.");
write_blk(h, blk, buf);
dquot->dq_dqb.u.v2_mdqb.dqb_off =

View File

@ -160,8 +160,7 @@ static int v2_check_file(struct quota_handle *h, int type, int fmt)
if (ext2fs_le32_to_cpu(dqh.dqh_magic) != file_magics[type]) {
if (ext2fs_be32_to_cpu(dqh.dqh_magic) == file_magics[type])
log_err("Your quota file is stored in wrong "
"endianity.", "");
log_err("Your quota file is stored in wrong endianity");
return 0;
}
if (V2_VERSION != ext2fs_le32_to_cpu(dqh.dqh_version))
@ -279,6 +278,6 @@ static int v2_scan_dquots(struct quota_handle *h,
*/
static int v2_report(struct quota_handle *h, int verbose)
{
log_err("Not Implemented.", "");
log_err("Not Implemented.");
return -1;
}