C++: Fix compiler warnings from gcc-4.7 on Fedora 18

Clang didn't complain about these. Note that some of the error messages
for not-clang in the tests have changed, likely due to C++. The old ones
are commented out for now; this part needs to be tested with an older
gcc to see if it's consistent.
This commit is contained in:
John Ralls
2014-04-26 11:10:56 -07:00
parent 403a0f6c42
commit 8f0098015c
9 changed files with 24 additions and 34 deletions

View File

@@ -200,7 +200,7 @@ win32_in_dst (GDateTime *date, TIME_ZONE_INFORMATION *tzinfo)
#endif
static GTimeZone*
gnc_g_time_zone_adjust_for_dst (GTimeZone* tz, GDateTime *date)
gnc_g_time_zone_adjust_for_dst (GTimeZone* tz, G_GNUC_UNUSED GDateTime *date)
{
#ifdef G_OS_WIN32
TIME_ZONE_INFORMATION tzinfo;
@@ -372,16 +372,12 @@ gnc_localtime (const time64 *secs)
struct tm*
gnc_localtime_r (const time64 *secs, struct tm* time)
{
guint index = 0;
GDateTime *gdt = gnc_g_date_time_new_from_unix_local (*secs);
g_return_val_if_fail (gdt != NULL, NULL);
gnc_g_date_time_fill_struct_tm (gdt, time);
if (g_date_time_is_daylight_savings (gdt))
{
index = 1;
time->tm_isdst = 1;
}
#ifdef HAVE_STRUCT_TM_GMTOFF
time->tm_gmtoff = g_date_time_get_utc_offset (gdt) / G_TIME_SPAN_SECOND;
@@ -411,7 +407,7 @@ normalize_time_component (gint *inner, gint *outer, guint divisor, gint base)
--(*outer);
*inner += divisor;
}
while (*inner > divisor)
while (*inner > static_cast<gint>(divisor))
{
++(*outer);
*inner -= divisor;
@@ -430,7 +426,6 @@ normalize_struct_tm (struct tm* time)
{
gint year = time->tm_year + 1900;
gint last_day;
time64 secs;
++time->tm_mon;
/* GDateTime doesn't protect itself against out-of range years,
@@ -1542,10 +1537,8 @@ gnc_iso8601_to_timespec_gmt(const char *str)
else if (fields > 6 && strlen (zone) > 0) /* Date string included a timezone */
{
GTimeZone *tz = g_time_zone_new (zone);
time64 secs;
second += 5e-10;
gdt = g_date_time_new (tz, year, month, day, hour, minute, second);
secs = g_date_time_to_unix (gdt);
}
else /* No zone info, assume UTC */
{
@@ -1609,7 +1602,6 @@ gnc_dmy2timespec_internal (int day, int month, int year, gboolean start_of_day)
Timespec result;
struct tm date;
long long secs = 0;
long long era = 0;
date.tm_year = year - 1900;
date.tm_mon = month - 1;

View File

@@ -235,7 +235,7 @@ g_hash_table_key_value_pairs(GHashTable *table)
}
void
g_hash_table_kv_pair_free_gfunc(gpointer data, gpointer user_data)
g_hash_table_kv_pair_free_gfunc(gpointer data, G_GNUC_UNUSED gpointer user_data)
{
GHashTableKVPair *kvp = (GHashTableKVPair *) data;
g_free(kvp);

View File

@@ -115,7 +115,7 @@ kvp_frame_new(void)
}
static void
kvp_frame_delete_worker(gpointer key, gpointer value, gpointer user_data)
kvp_frame_delete_worker(gpointer key, gpointer value, G_GNUC_UNUSED gpointer user_data)
{
qof_string_cache_remove(key);
kvp_value_delete((KvpValue *)value);
@@ -326,7 +326,7 @@ get_trailer_make (KvpFrame * frame, const char * key_path, char **end_key)
if (!frame || !key_path || (0 == key_path[0])) return NULL;
last_key = strrchr (key_path, '/');
last_key = strrchr (const_cast<char*>(key_path), '/');
if (NULL == last_key)
{
last_key = (char *) key_path;
@@ -368,7 +368,7 @@ get_trailer_or_null (const KvpFrame * frame, const char * key_path, char **end_k
if (!frame || !key_path || (0 == key_path[0])) return NULL;
last_key = strrchr (key_path, '/');
last_key = strrchr (const_cast<char*>(key_path), '/');
if (NULL == last_key)
{
last_key = (char *) key_path;

View File

@@ -115,12 +115,12 @@ book_final (gpointer key, gpointer value, gpointer booq)
}
static void
qof_book_dispose_real (GObject *bookp)
qof_book_dispose_real (G_GNUC_UNUSED GObject *bookp)
{
}
static void
qof_book_finalize_real (GObject *bookp)
qof_book_finalize_real (G_GNUC_UNUSED GObject *bookp)
{
}
@@ -336,7 +336,7 @@ struct _iterate
};
static void
foreach_cb (gpointer key, gpointer item, gpointer arg)
foreach_cb (G_GNUC_UNUSED gpointer key, gpointer item, gpointer arg)
{
struct _iterate *iter = static_cast<_iterate*>(arg);
QofCollection *col = static_cast<QofCollection*>(item);
@@ -746,13 +746,13 @@ qof_book_begin_edit (QofBook *book)
qof_begin_edit(&book->inst);
}
static void commit_err (QofInstance *inst, QofBackendError errcode)
static void commit_err (G_GNUC_UNUSED QofInstance *inst, QofBackendError errcode)
{
PERR ("Failed to commit: %d", errcode);
// gnc_engine_signal_commit_error( errcode );
}
static void noop (QofInstance *inst) {}
static void noop (G_GNUC_UNUSED QofInstance *inst) {}
void
qof_book_commit_edit(QofBook *book)

View File

@@ -317,7 +317,7 @@ qof_log_parse_log_config(const char *filename)
if (g_key_file_has_group(conf, levels_group))
{
gsize num_levels;
int key_idx;
unsigned int key_idx;
gchar **levels;
levels = g_key_file_get_keys(conf, levels_group, &num_levels, NULL);
@@ -343,7 +343,7 @@ qof_log_parse_log_config(const char *filename)
if (g_key_file_has_group(conf, output_group))
{
gsize num_outputs;
int output_idx;
unsigned int output_idx;
gchar **outputs;
outputs = g_key_file_get_keys(conf, output_group, &num_outputs, NULL);

View File

@@ -197,7 +197,7 @@ div128 (qofint128 n, gint64 d)
remainder <<= 1;
if (sbit) remainder |= 1;
quotient = shiftleft128 (quotient);
if (remainder >= d)
if (remainder >= static_cast<unsigned int64_t>(d))
{
remainder -= d;
quotient.lo |= 1;

View File

@@ -635,21 +635,15 @@ qof_session_save (QofSession *session,
QofPercentageFunc percentage_func)
{
QofBackend *be;
QofBackendProvider *prov;
GSList *p;
QofBook *book;
int err;
char *msg = NULL;
char *book_id;
if (!session) return;
if (!g_atomic_int_dec_and_test(&session->lock))
goto leave;
ENTER ("sess=%p book_id=%s",
session, session->book_id ? session->book_id : "(null)");
book = qof_session_get_book(session);
msg = g_strdup_printf(" ");
book_id = g_strdup(session->book_id);
/* If there is a backend, and the backend is reachable
* (i.e. we can communicate with it), then synchronize with
* the backend. If we cannot contact the backend (e.g.

View File

@@ -90,7 +90,8 @@ test_gnc_localtime (void)
#ifdef __clang__
#define _func "struct tm *gnc_localtime_r(const time64 *, struct tm *)"
#else
#define _func "gnc_localtime_r"
#define _func "tm* gnc_localtime_r(const time64*, tm*)"
//#define _func "gnc_localtime_r"
#endif
gchar *msg = _func ": assertion " _Q "gdt != NULL' failed";
#undef _func
@@ -161,7 +162,8 @@ test_gnc_gmtime (void)
#ifdef __clang__
#define _func "struct tm *gnc_gmtime(const time64 *)"
#else
#define _func "gnc_gmtime"
#define _func "tm* gnc_gmtime(const time64*)"
//#define _func "gnc_gmtime"
#endif
gchar *msg = _func ": assertion " _Q "gdt != NULL' failed";
#undef _func
@@ -1739,7 +1741,8 @@ test_gnc_timespec_to_iso8601_buff (void)
#ifdef __clang__
#define _func "char *gnc_timespec_to_iso8601_buff(Timespec, char *)"
#else
#define _func "gnc_timespec_to_iso8601_buff"
#define _func "char* gnc_timespec_to_iso8601_buff(Timespec, char*)"
//#define _func "gnc_timespec_to_iso8601_buff"
#endif
gchar *msg = _func ": assertion " _Q "buff != NULL' failed";
#undef _func

View File

@@ -620,10 +620,11 @@ test_book_foreach_collection( Fixture *fixture, gconstpointer pData )
QofIdType my_type = "my_type", my_type2 = "my_type2";
guint param = (guint) g_test_rand_int();
/* GLib assertion messages which aren't filtered to make clang's output like gcc's */
#ifdef __clang__
#if defined(__clang__)
#define _func "void qof_book_foreach_collection(const QofBook *, QofCollectionForeachCB, gpointer)"
#else
#define _func "qof_book_foreach_collection"
#define _func "void qof_book_foreach_collection(const QofBook*, QofCollectionForeachCB, gpointer)"
//#define _func "qof_book_foreach_collection"
#endif
gchar *msg1 = _func ": assertion " _Q "book' failed";
gchar *msg2 = _func ": assertion " _Q "cb' failed";