From 7eb244b3b0ad64d5f791bf6755c1532d1c5d76b7 Mon Sep 17 00:00:00 2001 From: djcb Date: Wed, 22 Apr 2015 21:06:31 +0300 Subject: [PATCH] mu: don't use __FUNCTION__, use __func__ __FUNCTION__ is deprecated and gives compilation warnings. __func__ is standardized in c99. --- configure.ac | 3 ++- guile/mu-guile.c | 2 +- lib/mu-index.c | 6 +++--- lib/mu-log.c | 6 +++--- lib/mu-maildir.c | 6 +++--- lib/mu-msg-file.c | 4 ++-- lib/mu-msg.c | 2 +- lib/mu-store-priv.hh | 4 ++-- lib/mu-store.cc | 2 +- lib/mu-str.c | 2 +- lib/mu-util.c | 6 +++--- lib/mu-util.h | 24 ++++++++++++------------ lib/tests/test-mu-flags.c | 2 +- lib/tests/test-mu-maildir.c | 2 +- mu/mu-cmd-server.c | 14 ++++++-------- toys/msg2pdf/msg2pdf.c | 4 ++-- toys/mug/mu-msg-attach-view.c | 2 +- toys/mug/mu-msg-body-view.c | 6 +++--- toys/mug/mug-msg-list-view.c | 2 +- 19 files changed, 49 insertions(+), 50 deletions(-) diff --git a/configure.ac b/configure.ac index ab4ff293..218813b3 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -## Copyright (C) 2008-2014 Dirk-Jan C. Binnema +## Copyright (C) 2008-2015 Dirk-Jan C. Binnema ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -33,6 +33,7 @@ AC_SUBST(prefix) AC_PROG_CXX AC_PROG_CC AC_PROG_CC_STDC +AC_PROG_CC_C99 AC_PROG_INSTALL AC_HEADER_STDC diff --git a/guile/mu-guile.c b/guile/mu-guile.c index 06f4d69d..145e8cb6 100644 --- a/guile/mu-guile.c +++ b/guile/mu-guile.c @@ -106,7 +106,7 @@ mu_guile_init_instance (const char *muhome) return TRUE; errexit: - mu_guile_g_error (__FUNCTION__, err); + mu_guile_g_error (__func__, err); g_clear_error (&err); return FALSE; } diff --git a/lib/mu-index.c b/lib/mu-index.c index 3b42dc50..259ac6c5 100644 --- a/lib/mu-index.c +++ b/lib/mu-index.c @@ -245,7 +245,7 @@ on_run_maildir_dir (const char* fullpath, gboolean enter, data->_user_data); if (err) { - MU_WRITE_LOG ("%s: %s", __FUNCTION__, err->message); + MU_WRITE_LOG ("%s: %s", __func__, err->message); g_clear_error(&err); } @@ -259,13 +259,13 @@ check_path (const char *path) if (!g_path_is_absolute (path)) { g_warning ("%s: not an absolute path: %s", - __FUNCTION__, path); + __func__, path); return FALSE; } if (access (path, R_OK) != 0) { g_warning ("%s: cannot open '%s': %s", - __FUNCTION__, path, strerror (errno)); + __func__, path, strerror (errno)); return FALSE; } diff --git a/lib/mu-log.c b/lib/mu-log.c index b9055d8f..923a2abd 100644 --- a/lib/mu-log.c +++ b/lib/mu-log.c @@ -67,7 +67,7 @@ try_close (int fd) if (close (fd) < 0) g_printerr ("%s: close() of fd %d failed: %s\n", - __FUNCTION__, fd, strerror(errno)); + __func__, fd, strerror(errno)); } static void @@ -190,7 +190,7 @@ mu_log_init (const char* logfile, MuLogOptions opts) fd = open (logfile, O_WRONLY|O_CREAT|O_APPEND, 00600); if (fd < 0) { - g_warning ("%s: open() of '%s' failed: %s", __FUNCTION__, + g_warning ("%s: open() of '%s' failed: %s", __func__, logfile, strerror(errno)); return FALSE; } @@ -275,7 +275,7 @@ log_write_fd (GLogLevelFlags level, const gchar *msg) err: fprintf (stderr, "%s: failed to write to log: %s\n", - __FUNCTION__, strerror(errno)); + __func__, strerror(errno)); } diff --git a/lib/mu-maildir.c b/lib/mu-maildir.c index d64c7f28..51c028bc 100644 --- a/lib/mu-maildir.c +++ b/lib/mu-maildir.c @@ -117,7 +117,7 @@ mu_maildir_mkdir (const char* path, mode_t mode, gboolean noindex, GError **err) { g_return_val_if_fail (path, FALSE); - MU_WRITE_LOG ("%s (%s, %o, %s)", __FUNCTION__, + MU_WRITE_LOG ("%s (%s, %o, %s)", __func__, path, mode, noindex ? "TRUE" : "FALSE"); if (!create_maildir (path, mode, err)) @@ -238,7 +238,7 @@ process_file (const char* fullpath, const gchar* mdir, g_debug ("callback said 'MU_STOP' for %s", fullpath); else if (result == MU_ERROR) g_warning ("%s: error in callback (%s)", - __FUNCTION__, fullpath); + __func__, fullpath); return result; } @@ -735,7 +735,7 @@ mu_maildir_get_maildir_from_path (const char* path) if (!g_str_has_suffix (mdir, "cur") && !g_str_has_suffix (mdir, "new")) { g_warning ("%s: not a valid maildir path: %s", - __FUNCTION__, path); + __func__, path); g_free (mdir); return NULL; } diff --git a/lib/mu-msg-file.c b/lib/mu-msg-file.c index debc22df..53259866 100644 --- a/lib/mu-msg-file.c +++ b/lib/mu-msg-file.c @@ -451,7 +451,7 @@ stream_to_string (GMimeStream *stream, size_t buflen) /* we read everything in one go */ bytes = g_mime_stream_read (stream, buffer, buflen); if (bytes < 0) { - g_warning ("%s: failed to read from stream", __FUNCTION__); + g_warning ("%s: failed to read from stream", __func__); g_free (buffer); return NULL; } @@ -695,7 +695,7 @@ mu_msg_file_get_str_field (MuMsgFile *self, MuMsgFieldId mfid, case MU_MSG_FIELD_ID_BODY_HTML: /* use mu_msg_get_body_html */ case MU_MSG_FIELD_ID_EMBEDDED_TEXT: g_warning ("%s is not retrievable through: %s", - mu_msg_field_name (mfid), __FUNCTION__); + mu_msg_field_name (mfid), __func__); return NULL; default: g_return_val_if_reached (NULL); diff --git a/lib/mu-msg.c b/lib/mu-msg.c index f8c8a6a1..ccba50e3 100644 --- a/lib/mu-msg.c +++ b/lib/mu-msg.c @@ -209,7 +209,7 @@ get_path (MuMsg *self) /* shouldn't happen */ if (!val) - g_warning ("%s: cannot find path", __FUNCTION__); + g_warning ("%s: cannot find path", __func__); return free_later_str (self, val); } diff --git a/lib/mu-store-priv.hh b/lib/mu-store-priv.hh index 6271b7e7..7c1d17ed 100644 --- a/lib/mu-store-priv.hh +++ b/lib/mu-store-priv.hh @@ -77,7 +77,7 @@ public: } MU_WRITE_LOG ("%s: opened %s (batch size: %u) for read-write", - __FUNCTION__, this->path(), (unsigned)batch_size()); + __func__, this->path(), (unsigned)batch_size()); } /* create a read-only MuStore */ @@ -97,7 +97,7 @@ public: g_free (errstr); throw exc; } - MU_WRITE_LOG ("%s: opened %s read-only", __FUNCTION__, this->path()); + MU_WRITE_LOG ("%s: opened %s read-only", __func__, this->path()); } void init (const char *path, const char *contacts_path, diff --git a/lib/mu-store.cc b/lib/mu-store.cc index 4def9e33..21410064 100644 --- a/lib/mu-store.cc +++ b/lib/mu-store.cc @@ -108,7 +108,7 @@ mu_store_database_is_locked (const gchar *xpath) } catch (const Xapian::DatabaseLockError& xer) { return TRUE; } catch (const Xapian::Error &xer) { - g_warning ("%s: error: %s", __FUNCTION__, + g_warning ("%s: error: %s", __func__, xer.get_msg().c_str()); } diff --git a/lib/mu-str.c b/lib/mu-str.c index 0a5e510d..944173f6 100644 --- a/lib/mu-str.c +++ b/lib/mu-str.c @@ -888,7 +888,7 @@ mu_str_convert_to_utf8 (const char* buffer, const char *charset) if (!utf8) { g_warning ("%s: conversion failed from %s: %s", - __FUNCTION__, charset, err ? err->message : ""); + __func__, charset, err ? err->message : ""); } g_clear_error (&err); diff --git a/lib/mu-util.c b/lib/mu-util.c index 842b1449..fd664b3d 100644 --- a/lib/mu-util.c +++ b/lib/mu-util.c @@ -55,12 +55,12 @@ do_wordexp (const char *path) char *dir; if (!path) { - /* g_debug ("%s: path is empty", __FUNCTION__); */ + /* g_debug ("%s: path is empty", __func__); */ return NULL; } if (wordexp (path, &wexp, 0) != 0) { - /* g_debug ("%s: expansion failed for %s", __FUNCTION__, path); */ + /* g_debug ("%s: expansion failed for %s", __func__, path); */ return NULL; } @@ -108,7 +108,7 @@ mu_util_dir_expand (const char *path) /* now resolve any symlinks, .. etc. */ if (realpath (dir, resolved) == NULL) { /* g_debug ("%s: could not get realpath for '%s': %s", */ - /* __FUNCTION__, dir, strerror(errno)); */ + /* __func__, dir, strerror(errno)); */ g_free (dir); return NULL; } else diff --git a/lib/mu-util.h b/lib/mu-util.h index 22fa5784..5e941321 100644 --- a/lib/mu-util.h +++ b/lib/mu-util.h @@ -313,7 +313,7 @@ typedef gpointer XapianEnquire; do { \ if (!(GE)) \ g_warning ("%s:%u: an error occured in %s", \ - __FILE__, __LINE__, __FUNCTION__); \ + __FILE__, __LINE__, __func__); \ else { \ g_warning ("error %u: %s", (GE)->code, (GE)->message); \ g_error_free ((GE)); \ @@ -339,9 +339,9 @@ typedef gpointer XapianEnquire; #define MU_XAPIAN_CATCH_BLOCK \ catch (const Xapian::Error &xerr) { \ g_critical ("%s: xapian error '%s'", \ - __FUNCTION__, xerr.get_msg().c_str()); \ + __func__, xerr.get_msg().c_str()); \ } catch (...) { \ - g_critical ("%s: caught exception", __FUNCTION__); \ + g_critical ("%s: caught exception", __func__); \ } #define MU_XAPIAN_CATCH_BLOCK_G_ERROR(GE,E) \ @@ -349,33 +349,33 @@ typedef gpointer XapianEnquire; mu_util_g_set_error ((GE), \ MU_ERROR_XAPIAN_CANNOT_GET_WRITELOCK, \ "%s: xapian error '%s'", \ - __FUNCTION__, xerr.get_msg().c_str()); \ + __func__, xerr.get_msg().c_str()); \ } catch (const Xapian::DatabaseCorruptError &xerr) { \ mu_util_g_set_error ((GE), \ MU_ERROR_XAPIAN_CORRUPTION, \ "%s: xapian error '%s'", \ - __FUNCTION__, xerr.get_msg().c_str()); \ + __func__, xerr.get_msg().c_str()); \ } catch (const Xapian::DatabaseError &xerr) { \ mu_util_g_set_error ((GE),MU_ERROR_XAPIAN, \ "%s: xapian error '%s'", \ - __FUNCTION__, xerr.get_msg().c_str()); \ + __func__, xerr.get_msg().c_str()); \ } catch (const Xapian::Error &xerr) { \ mu_util_g_set_error ((GE),(E), \ "%s: xapian error '%s'", \ - __FUNCTION__, xerr.get_msg().c_str()); \ + __func__, xerr.get_msg().c_str()); \ } catch (...) { \ mu_util_g_set_error ((GE),(MU_ERROR_INTERNAL), \ - "%s: caught exception", __FUNCTION__); \ + "%s: caught exception", __func__); \ } #define MU_XAPIAN_CATCH_BLOCK_RETURN(R) \ catch (const Xapian::Error &xerr) { \ g_critical ("%s: xapian error '%s'", \ - __FUNCTION__, xerr.get_msg().c_str()); \ + __func__, xerr.get_msg().c_str()); \ return (R); \ } catch (...) { \ - g_critical ("%s: caught exception", __FUNCTION__); \ + g_critical ("%s: caught exception", __func__); \ return (R); \ } @@ -383,13 +383,13 @@ typedef gpointer XapianEnquire; catch (const Xapian::Error &xerr) { \ mu_util_g_set_error ((GE),(E), \ "%s: xapian error '%s'", \ - __FUNCTION__, xerr.get_msg().c_str()); \ + __func__, xerr.get_msg().c_str()); \ return (R); \ } catch (...) { \ if ((GE)&&!(*(GE))) \ mu_util_g_set_error ((GE), \ (MU_ERROR_INTERNAL), \ - "%s: caught exception", __FUNCTION__); \ + "%s: caught exception", __func__); \ return (R); \ } diff --git a/lib/tests/test-mu-flags.c b/lib/tests/test-mu-flags.c index b584fc15..36db9c8a 100644 --- a/lib/tests/test-mu-flags.c +++ b/lib/tests/test-mu-flags.c @@ -160,7 +160,7 @@ test_mu_flags_custom_from_str (void) cust = mu_flags_custom_from_str (cases[u].str); if (g_test_verbose()) g_print ("%s: str:%s; got:%s; expected:%s\n", - __FUNCTION__, cases[u].str, cust, cases[u].expected); + __func__, cases[u].str, cust, cases[u].expected); g_assert_cmpstr (cust, ==, cases[u].expected); g_free (cust); } diff --git a/lib/tests/test-mu-maildir.c b/lib/tests/test-mu-maildir.c index cb473eb6..358ad9c6 100644 --- a/lib/tests/test-mu-maildir.c +++ b/lib/tests/test-mu-maildir.c @@ -227,7 +227,7 @@ dir_cb (const char *fullpath, gboolean enter, WalkData *data) ++data->_dir_left; if (g_test_verbose()) - g_print ("%s: %s: %s (%u)\n", __FUNCTION__, enter ? "entering" : "leaving", + g_print ("%s: %s: %s (%u)\n", __func__, enter ? "entering" : "leaving", fullpath, enter ? data->_dir_entered : data->_dir_left); return MU_OK; diff --git a/mu/mu-cmd-server.c b/mu/mu-cmd-server.c index c97a7398..b349c2d0 100644 --- a/mu/mu-cmd-server.c +++ b/mu/mu-cmd-server.c @@ -134,7 +134,7 @@ print_expr (const char* frm, ...) rv = write (outfd, "\n", 1); if (rv == -1) { g_critical ("%s: write() failed: %s", - __FUNCTION__, strerror(errno)); + __func__, strerror(errno)); /* terminate ourselves */ raise (SIGTERM); } @@ -976,14 +976,12 @@ cmd_find (ServerContext *ctx, GHashTable *args, GError **err) static MuError cmd_guile (ServerContext *ctx, GHashTable *args, GError **err) { - const char *script, *file; + const char *eval; - script = get_string_from_args (args, "script", TRUE, NULL); - file = get_string_from_args (args, "file", TRUE, NULL); - - if (!script == !file) { - print_error (MU_ERROR_IN_PARAMETERS, - "guile: must provide one of 'script', 'file'"); + eval = get_string_from_args (args, "eval", TRUE, NULL); + + if (!eval) { + print_error (MU_ERROR_IN_PARAMETERS, "guile: expected: 'eval'"); return MU_OK; } diff --git a/toys/msg2pdf/msg2pdf.c b/toys/msg2pdf/msg2pdf.c index e49a8798..e873ab58 100644 --- a/toys/msg2pdf/msg2pdf.c +++ b/toys/msg2pdf/msg2pdf.c @@ -74,7 +74,7 @@ save_file_for_cid (MuMsg *msg, const char* cid) idx = mu_msg_find_index_for_cid (msg, MU_MSG_OPTION_NONE, cid); if (idx < 0) { - g_warning ("%s: cannot find %s", __FUNCTION__, cid); + g_warning ("%s: cannot find %s", __func__, cid); return NULL; } @@ -90,7 +90,7 @@ save_file_for_cid (MuMsg *msg, const char* cid) return filepath; errexit: - g_warning ("%s: failed to save %s: %s", __FUNCTION__, + g_warning ("%s: failed to save %s: %s", __func__, filepath, err&&err->message?err->message:"error"); g_clear_error (&err); diff --git a/toys/mug/mu-msg-attach-view.c b/toys/mug/mu-msg-attach-view.c index fb128178..630f0772 100644 --- a/toys/mug/mu-msg-attach-view.c +++ b/toys/mug/mu-msg-attach-view.c @@ -253,7 +253,7 @@ each_part (MuMsg *msg, MuMsgPart *part, CBData *cbdata) pixbuf = mu_widget_util_get_icon_pixbuf_for_content_type (ctype, 16); if (!pixbuf) { g_debug ("%s: could not get icon pixbuf for '%s'", - __FUNCTION__, ctype); + __func__, ctype); pixbuf = mu_widget_util_get_icon_pixbuf_for_content_type ("application/octet-stream", 16); } diff --git a/toys/mug/mu-msg-body-view.c b/toys/mug/mu-msg-body-view.c index 29dd7040..43b26f88 100644 --- a/toys/mug/mu-msg-body-view.c +++ b/toys/mug/mu-msg-body-view.c @@ -110,7 +110,7 @@ save_file_for_cid (MuMsg *msg, const char* cid) idx = mu_msg_find_index_for_cid (msg, MU_MSG_OPTION_NONE, cid); if (idx < 0) { - g_warning ("%s: cannot find %s", __FUNCTION__, cid); + g_warning ("%s: cannot find %s", __func__, cid); return NULL; } @@ -124,7 +124,7 @@ save_file_for_cid (MuMsg *msg, const char* cid) rv = mu_msg_part_save (msg, MU_MSG_OPTION_USE_EXISTING, filepath, idx, &err); if (!rv) { - g_warning ("%s: failed to save %s: %s", __FUNCTION__, filepath, + g_warning ("%s: failed to save %s: %s", __func__, filepath, err&&err->message?err->message:"error"); g_clear_error (&err); g_free (filepath); @@ -193,7 +193,7 @@ on_resource_request_starting (MuMsgBodyView *self, WebKitWebFrame *frame, msg = self->_priv->_msg; uri = webkit_network_request_get_uri (request); - /* g_warning ("%s: %s", __FUNCTION__, uri); */ + /* g_warning ("%s: %s", __func__, uri); */ if (g_ascii_strncasecmp (uri, "cid:", 4) == 0) { gchar *filepath; diff --git a/toys/mug/mug-msg-list-view.c b/toys/mug/mug-msg-list-view.c index d084c4be..5110622a 100644 --- a/toys/mug/mug-msg-list-view.c +++ b/toys/mug/mug-msg-list-view.c @@ -382,7 +382,7 @@ add_row (GtkTreeStore * store, MuMsg *msg, GtkTreeIter *treeiter) /* if (!gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL(store), */ /* &myiter, path)) */ /* g_warning ("%s: cannot get iter for %s", - * __FUNCTION__, path); */ + * __func__, path); */ /* } */ gtk_tree_store_set (store, treeiter,