diff --git a/wsutil/802_11-utils.c b/wsutil/802_11-utils.c index 2f467f446c..53cd080cb3 100644 --- a/wsutil/802_11-utils.c +++ b/wsutil/802_11-utils.c @@ -9,9 +9,6 @@ */ #include "config.h" - -#include - #include "802_11-utils.h" typedef struct freq_cvt_s { @@ -95,9 +92,9 @@ ieee80211_mhz_to_str(guint freq){ gboolean is_bg = FREQ_IS_BG(freq); if (chan < 0) { - return g_strdup_printf("%u", freq); + return ws_strdup_printf("%u", freq); } else { - return g_strdup_printf("%u [%s %u]", freq, is_bg ? "BG" : "A", + return ws_strdup_printf("%u [%s %u]", freq, is_bg ? "BG" : "A", chan); } } diff --git a/wsutil/802_11-utils.h b/wsutil/802_11-utils.h index fcb6ab8fe7..c8d4b4de1e 100644 --- a/wsutil/802_11-utils.h +++ b/wsutil/802_11-utils.h @@ -11,7 +11,7 @@ #ifndef __802_11_UTILS_H__ #define __802_11_UTILS_H__ -#include "ws_symbol_export.h" +#include #ifdef __cplusplus extern "C" { diff --git a/wsutil/buffer.c b/wsutil/buffer.c index 3b6894500a..c7c6fe752c 100644 --- a/wsutil/buffer.c +++ b/wsutil/buffer.c @@ -114,7 +114,7 @@ ws_buffer_remove_start(Buffer* buffer, gsize bytes) { ws_assert(buffer); if (buffer->start + bytes > buffer->first_free) { - ws_error("ws_buffer_remove_start trying to remove %" G_GINT64_MODIFIER "u bytes. s=%" G_GINT64_MODIFIER "u ff=%" G_GINT64_MODIFIER "u!\n", + ws_error("ws_buffer_remove_start trying to remove %" PRIu64 " bytes. s=%" PRIu64 " ff=%" PRIu64 "!\n", (guint64)bytes, (guint64)buffer->start, (guint64)buffer->first_free); /** ws_error() does an abort() and thus never returns **/ diff --git a/wsutil/crash_info.c b/wsutil/crash_info.c index 17ee196493..d56eaabe3a 100644 --- a/wsutil/crash_info.c +++ b/wsutil/crash_info.c @@ -131,12 +131,12 @@ ws_vadd_crash_info(const char *fmt, va_list ap) { char *m, *old_info, *new_info; - m = g_strdup_vprintf(fmt, ap); + m = ws_strdup_vprintf(fmt, ap); if (__crashreporter_info__ == NULL) __crashreporter_info__ = m; else { old_info = __crashreporter_info__; - new_info = g_strdup_printf("%s\n%s", old_info, m); + new_info = ws_strdup_printf("%s\n%s", old_info, m); g_free(m); __crashreporter_info__ = new_info; g_free(old_info); diff --git a/wsutil/filesystem.c b/wsutil/filesystem.c index 355ce74353..e0bb8e4df9 100644 --- a/wsutil/filesystem.c +++ b/wsutil/filesystem.c @@ -8,15 +8,14 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ -#include +#include "config.h" +#include "filesystem.h" #include #include #include #include -#include - #ifdef _WIN32 #include #include @@ -39,12 +38,10 @@ #include #endif /* _WIN32 */ -#include "filesystem.h" #include #include #include #include -#include #include /* for WTAP_ERR_SHORT_WRITE */ @@ -507,7 +504,7 @@ init_progfile_dir( /* * OK, no. What do we do now? */ - return g_strdup_printf("No \\ in executable pathname \"%s\"", + return ws_strdup_printf("No \\ in executable pathname \"%s\"", prog_pathname); } } else { @@ -520,7 +517,7 @@ init_progfile_dir( /* * Gak. We can't format the message. */ - return g_strdup_printf("GetModuleFileName failed: %u (FormatMessage failed: %u)", + return ws_strdup_printf("GetModuleFileName failed: %u (FormatMessage failed: %u)", error, GetLastError()); } msg = utf_16to8(msg_w); @@ -534,7 +531,7 @@ init_progfile_dir( msg[msglen - 1] = '\0'; msg[msglen - 2] = '\0'; } - return g_strdup_printf("GetModuleFileName failed: %s (%u)", + return ws_strdup_printf("GetModuleFileName failed: %s (%u)", msg, error); } #else @@ -597,7 +594,7 @@ init_progfile_dir( * We have no idea how big a buffer to * allocate for the current directory. */ - return g_strdup_printf("pathconf failed: %s\n", + return ws_strdup_printf("pathconf failed: %s\n", g_strerror(errno)); } curdir = (char *)g_malloc(path_max); @@ -607,10 +604,10 @@ init_progfile_dir( * with DATA_DIR. */ g_free(curdir); - return g_strdup_printf("getcwd failed: %s\n", + return ws_strdup_printf("getcwd failed: %s\n", g_strerror(errno)); } - path = g_strdup_printf("%s/%s", curdir, execname); + path = ws_strdup_printf("%s/%s", curdir, execname); g_free(curdir); prog_pathname = path; } else { @@ -656,7 +653,7 @@ init_progfile_dir( /* * Program not found in path. */ - return g_strdup_printf("\"%s\" not found in \"%s\"", + return ws_strdup_printf("\"%s\" not found in \"%s\"", execname, pathstr); } } else { @@ -696,7 +693,7 @@ init_progfile_dir( */ if (strcmp(dir_end, "/run") == 0) { gchar *cmake_file; - cmake_file = g_strdup_printf("%.*s/CMakeCache.txt", + cmake_file = ws_strdup_printf("%.*s/CMakeCache.txt", (int)(dir_end - prog_pathname), prog_pathname); if (file_exists(cmake_file)) @@ -761,7 +758,7 @@ init_progfile_dir( * have no "/" in the pathname. * Just free up prog_pathname. */ - retstr = g_strdup_printf("No / found in \"%s\"", prog_pathname); + retstr = ws_strdup_printf("No / found in \"%s\"", prog_pathname); g_free(prog_pathname); return retstr; } @@ -863,7 +860,7 @@ get_datafile_dir(void) * it; we don't need to call started_with_special_privs().) */ else if (appbundle_dir != NULL) { - datafile_dir = g_strdup_printf("%s/Contents/Resources/share/wireshark", + datafile_dir = ws_strdup_printf("%s/Contents/Resources/share/wireshark", appbundle_dir); } #endif @@ -1194,7 +1191,7 @@ has_global_profiles(void) ((dir = ws_dir_open(global_dir, 0, NULL)) != NULL)) { while ((file = ws_dir_read_name(dir)) != NULL) { - filename = g_strdup_printf ("%s%s%s", global_dir, G_DIR_SEPARATOR_S, + filename = ws_strdup_printf ("%s%s%s", global_dir, G_DIR_SEPARATOR_S, ws_dir_get_name(file)); if (test_for_directory(filename) == EISDIR) { has_global = TRUE; @@ -1368,7 +1365,7 @@ set_persconffile_dir(const char *p) char * get_profiles_dir(void) { - return g_strdup_printf ("%s%s%s", get_persconffile_dir_no_profile (), + return ws_strdup_printf ("%s%s%s", get_persconffile_dir_no_profile (), G_DIR_SEPARATOR_S, PROFILES_DIR); } @@ -1414,7 +1411,7 @@ create_profiles_dir(char **pf_dir_path_return) char * get_global_profiles_dir(void) { - return g_strdup_printf ("%s%s%s", get_datafile_dir(), + return ws_strdup_printf ("%s%s%s", get_datafile_dir(), G_DIR_SEPARATOR_S, PROFILES_DIR); } @@ -1426,7 +1423,7 @@ get_persconffile_dir(const gchar *profilename) if (profilename && strlen(profilename) > 0 && strcmp(profilename, DEFAULT_PROFILE) != 0) { profile_dir = get_profiles_dir(); - persconffile_profile_dir = g_strdup_printf ("%s%s%s", profile_dir, + persconffile_profile_dir = ws_strdup_printf ("%s%s%s", profile_dir, G_DIR_SEPARATOR_S, profilename); g_free(profile_dir); } else { @@ -1492,7 +1489,7 @@ delete_directory (const char *directory, char **pf_dir_path_return) if ((dir = ws_dir_open(directory, 0, NULL)) != NULL) { while ((file = ws_dir_read_name(dir)) != NULL) { - filename = g_strdup_printf ("%s%s%s", directory, G_DIR_SEPARATOR_S, + filename = ws_strdup_printf ("%s%s%s", directory, G_DIR_SEPARATOR_S, ws_dir_get_name(file)); if (test_for_directory(filename) != EISDIR) { ret = ws_remove(filename); @@ -1531,7 +1528,7 @@ reset_default_profile(char **pf_dir_path_return) file = g_list_first(files); while (file) { filename = (gchar *)file->data; - del_file = g_strdup_printf("%s%s%s", profile_dir, G_DIR_SEPARATOR_S, filename); + del_file = ws_strdup_printf("%s%s%s", profile_dir, G_DIR_SEPARATOR_S, filename); if (file_exists(del_file)) { ret = ws_remove(del_file); @@ -1716,8 +1713,8 @@ copy_persconffile_profile(const char *toname, const char *fromname, gboolean fro file = g_list_first(files); while (file) { filename = (gchar *)file->data; - from_file = g_strdup_printf ("%s%s%s", from_dir, G_DIR_SEPARATOR_S, filename); - to_file = g_strdup_printf ("%s%s%s", to_dir, G_DIR_SEPARATOR_S, filename); + from_file = ws_strdup_printf ("%s%s%s", from_dir, G_DIR_SEPARATOR_S, filename); + to_file = ws_strdup_printf ("%s%s%s", to_dir, G_DIR_SEPARATOR_S, filename); if (file_exists(from_file) && !copy_file_binary_mode(from_file, to_file)) { *pf_filename_return = g_strdup(filename); @@ -1810,7 +1807,7 @@ get_home_dir(void) * This is cached, so we don't need to worry about * allocating multiple ones of them. */ - homestring = g_strdup_printf("%s%s", homedrive, homepath); + homestring = ws_strdup_printf("%s%s", homedrive, homepath); /* * Trim off any trailing slash or backslash. @@ -1988,7 +1985,7 @@ file_open_error_message(int err, gboolean for_writing) break; default: - g_snprintf(errmsg_errno, sizeof(errmsg_errno), + snprintf(errmsg_errno, sizeof(errmsg_errno), "The file \"%%s\" could not be %s: %s.", for_writing ? "created" : "opened", g_strerror(err)); @@ -2021,7 +2018,7 @@ file_write_error_message(int err) #endif default: - g_snprintf(errmsg_errno, sizeof(errmsg_errno), + snprintf(errmsg_errno, sizeof(errmsg_errno), "An error occurred while writing to the file \"%%s\": %s.", g_strerror(err)); errmsg = errmsg_errno; @@ -2337,7 +2334,7 @@ data_file_url(const gchar *filename) if(g_path_is_absolute(filename)) { file_path = g_strdup(filename); } else { - file_path = g_strdup_printf("%s/%s", get_datafile_dir(), filename); + file_path = ws_strdup_printf("%s/%s", get_datafile_dir(), filename); } /* XXX - check, if the file is really existing, otherwise display a simple_dialog about the problem */ diff --git a/wsutil/filesystem.h b/wsutil/filesystem.h index 2a7f95647d..b3acd76807 100644 --- a/wsutil/filesystem.h +++ b/wsutil/filesystem.h @@ -11,8 +11,7 @@ #ifndef FILESYSTEM_H #define FILESYSTEM_H -#include "ws_symbol_export.h" -#include "ws_attributes.h" +#include #ifdef __cplusplus extern "C" { diff --git a/wsutil/rsa.c b/wsutil/rsa.c index 632d36c908..1a8d09c4db 100644 --- a/wsutil/rsa.c +++ b/wsutil/rsa.c @@ -56,7 +56,7 @@ rsa_privkey_to_sexp(gnutls_x509_privkey_t priv_key, char **err) /* these buffers were allocated by gnutls_x509_privkey_export_rsa_raw() */ g_free(rsa_datum[i].data); if (gret != 0) { - *err = g_strdup_printf("can't convert m rsa param to int (size %d)", rsa_datum[i].size); + *err = ws_strdup_printf("can't convert m rsa param to int (size %d)", rsa_datum[i].size); return NULL; } } @@ -101,7 +101,7 @@ rsa_load_pem_key(FILE *fp, char **err) *err = NULL; if (ws_fstat64(ws_fileno(fp), &statbuf) == -1) { - *err = g_strdup_printf("can't ws_fstat64 file: %s", g_strerror(errno)); + *err = ws_strdup_printf("can't ws_fstat64 file: %s", g_strerror(errno)); return NULL; } if (S_ISDIR(statbuf.st_mode)) { @@ -126,10 +126,10 @@ rsa_load_pem_key(FILE *fp, char **err) bytes = (guint) fread(key.data, 1, key.size, fp); if (bytes < key.size) { if (bytes == 0 && ferror(fp)) { - *err = g_strdup_printf("can't read from file %d bytes, got error %s", + *err = ws_strdup_printf("can't read from file %d bytes, got error %s", key.size, g_strerror(errno)); } else { - *err = g_strdup_printf("can't read from file %d bytes, got %d", + *err = ws_strdup_printf("can't read from file %d bytes, got %d", key.size, bytes); } g_free(key.data); @@ -141,7 +141,7 @@ rsa_load_pem_key(FILE *fp, char **err) /* import PEM data*/ if ((ret = gnutls_x509_privkey_import(priv_key, &key, GNUTLS_X509_FMT_PEM)) != GNUTLS_E_SUCCESS) { - *err = g_strdup_printf("can't import pem data: %s", gnutls_strerror(ret)); + *err = ws_strdup_printf("can't import pem data: %s", gnutls_strerror(ret)); g_free(key.data); gnutls_x509_privkey_deinit(priv_key); return NULL; @@ -211,7 +211,7 @@ rsa_load_pkcs12(FILE *fp, const gchar *cert_passwd, char **err) ret = gnutls_pkcs12_init(&rsa_p12); if (ret < 0) { - *err = g_strdup_printf("gnutls_pkcs12_init(&st_p12) - %s", gnutls_strerror(ret)); + *err = ws_strdup_printf("gnutls_pkcs12_init(&st_p12) - %s", gnutls_strerror(ret)); g_free(data.data); return NULL; } @@ -221,7 +221,7 @@ rsa_load_pkcs12(FILE *fp, const gchar *cert_passwd, char **err) if (ret < 0) { ret = gnutls_pkcs12_import(rsa_p12, &data, GNUTLS_X509_FMT_PEM, 0); if (ret < 0) { - *err = g_strdup_printf("could not load PKCS#12 in DER or PEM format: %s", gnutls_strerror(ret)); + *err = ws_strdup_printf("could not load PKCS#12 in DER or PEM format: %s", gnutls_strerror(ret)); } } g_free(data.data); @@ -238,14 +238,14 @@ rsa_load_pkcs12(FILE *fp, const gchar *cert_passwd, char **err) ret = gnutls_pkcs12_bag_init(&bag); if (ret < 0) { - *err = g_strdup_printf("gnutls_pkcs12_bag_init failed: %s", + *err = ws_strdup_printf("gnutls_pkcs12_bag_init failed: %s", gnutls_strerror(ret)); goto done; } ret = gnutls_pkcs12_get_bag(rsa_p12, i, bag); if (ret < 0) { - *err = g_strdup_printf("gnutls_pkcs12_get_bag failed: %s", + *err = ws_strdup_printf("gnutls_pkcs12_get_bag failed: %s", gnutls_strerror(ret)); goto done; } @@ -254,13 +254,13 @@ rsa_load_pkcs12(FILE *fp, const gchar *cert_passwd, char **err) ret = gnutls_pkcs12_bag_get_type(bag, j); if (ret < 0) { - *err = g_strdup_printf("gnutls_pkcs12_bag_get_type failed: %s", + *err = ws_strdup_printf("gnutls_pkcs12_bag_get_type failed: %s", gnutls_strerror(ret)); goto done; } bag_type = (gnutls_pkcs12_bag_type_t)ret; if (bag_type >= GNUTLS_BAG_UNKNOWN) { - *err = g_strdup_printf("gnutls_pkcs12_bag_get_type returned unknown bag type %u", + *err = ws_strdup_printf("gnutls_pkcs12_bag_get_type returned unknown bag type %u", ret); goto done; } @@ -270,13 +270,13 @@ rsa_load_pkcs12(FILE *fp, const gchar *cert_passwd, char **err) if (ret == 0) { ret = gnutls_pkcs12_bag_get_type(bag, j); if (ret < 0) { - *err = g_strdup_printf("gnutls_pkcs12_bag_get_type failed: %s", + *err = ws_strdup_printf("gnutls_pkcs12_bag_get_type failed: %s", gnutls_strerror(ret)); goto done; } bag_type = (gnutls_pkcs12_bag_type_t)ret; if (bag_type >= GNUTLS_BAG_UNKNOWN) { - *err = g_strdup_printf("gnutls_pkcs12_bag_get_type returned unknown bag type %u", + *err = ws_strdup_printf("gnutls_pkcs12_bag_get_type returned unknown bag type %u", ret); goto done; } @@ -286,7 +286,7 @@ rsa_load_pkcs12(FILE *fp, const gchar *cert_passwd, char **err) ret = gnutls_pkcs12_bag_get_data(bag, j, &data); if (ret < 0) { - *err = g_strdup_printf("gnutls_pkcs12_bag_get_data failed: %s", + *err = ws_strdup_printf("gnutls_pkcs12_bag_get_data failed: %s", gnutls_strerror(ret)); goto done; } @@ -300,13 +300,13 @@ rsa_load_pkcs12(FILE *fp, const gchar *cert_passwd, char **err) ret = gnutls_x509_privkey_init(&rsa_pkey); if (ret < 0) { - *err = g_strdup_printf("gnutls_x509_privkey_init failed: %s", gnutls_strerror(ret)); + *err = ws_strdup_printf("gnutls_x509_privkey_init failed: %s", gnutls_strerror(ret)); goto done; } ret = gnutls_x509_privkey_import_pkcs8(rsa_pkey, &data, GNUTLS_X509_FMT_DER, cert_passwd, (bag_type==GNUTLS_BAG_PKCS8_KEY) ? GNUTLS_PKCS_PLAIN : 0); if (ret < 0) { - *err = g_strdup_printf("Can not decrypt private key - %s", gnutls_strerror(ret)); + *err = ws_strdup_printf("Can not decrypt private key - %s", gnutls_strerror(ret)); gnutls_x509_privkey_deinit(rsa_pkey); goto done; } diff --git a/wsutil/socket.c b/wsutil/socket.c index 2e69caf6a5..dea495e5fb 100644 --- a/wsutil/socket.c +++ b/wsutil/socket.c @@ -10,16 +10,13 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ -#include +#include "config.h" +#include "socket.h" #include -#include #include -#include -#include #include -#include #ifdef _WIN32 #include @@ -38,7 +35,7 @@ ws_init_sockets(void) wVersionRequested = MAKEWORD(2, 2); err = WSAStartup(wVersionRequested, &wsaData); if (err != 0) { - errmsg = g_strdup_printf("Couldn't initialize Windows Sockets: %s", + errmsg = ws_strdup_printf("Couldn't initialize Windows Sockets: %s", win32strerror(err)); } #endif diff --git a/wsutil/socket.h b/wsutil/socket.h index 8387ecf2f4..cc0a7c1662 100644 --- a/wsutil/socket.h +++ b/wsutil/socket.h @@ -12,7 +12,7 @@ #ifndef __SOCKET_H__ #define __SOCKET_H__ -#include "ws_symbol_export.h" +#include #if defined(_WIN32) && !defined(__CYGWIN__) #include diff --git a/wsutil/str_util.c b/wsutil/str_util.c index 7392c98f8a..a1953baeaa 100644 --- a/wsutil/str_util.c +++ b/wsutil/str_util.c @@ -373,10 +373,10 @@ static void test_printf_thousands_grouping(void) { wmem_strbuf_t *buf = wmem_strbuf_new(NULL, NULL); wmem_strbuf_append_printf(buf, "%'d", 22); if (g_strcmp0(wmem_strbuf_get_str(buf), "22") == 0) { - thousands_grouping_fmt = "%'"G_GINT64_MODIFIER"d"; + thousands_grouping_fmt = "%'"PRId64; } else { /* Don't use */ - thousands_grouping_fmt = "%"G_GINT64_MODIFIER"d"; + thousands_grouping_fmt = "%"PRId64; } wmem_strbuf_destroy(buf); } diff --git a/wsutil/tempfile.c b/wsutil/tempfile.c index 9dee0d5103..a4d1ad5181 100644 --- a/wsutil/tempfile.c +++ b/wsutil/tempfile.c @@ -9,8 +9,6 @@ */ #include "config.h" - -#include #include "tempfile.h" /** @@ -46,7 +44,7 @@ create_tempfile(gchar **namebuf, const char *pfx, const char *sfx, GError **err) safe_pfx = g_strdelimit(safe_pfx, delimiters, '-'); } - gchar* filetmpl = g_strdup_printf("%sXXXXXX%s", safe_pfx ? safe_pfx : "", sfx ? sfx : ""); + gchar* filetmpl = ws_strdup_printf("%sXXXXXX%s", safe_pfx ? safe_pfx : "", sfx ? sfx : ""); g_free(safe_pfx); fd = g_file_open_tmp(filetmpl, namebuf, err); diff --git a/wsutil/tempfile.h b/wsutil/tempfile.h index 2b51089c24..49e344840a 100644 --- a/wsutil/tempfile.h +++ b/wsutil/tempfile.h @@ -11,7 +11,7 @@ #ifndef __TEMPFILE_H__ #define __TEMPFILE_H__ -#include "ws_symbol_export.h" +#include #ifdef __cplusplus extern "C" { diff --git a/wsutil/unicode-utils.c b/wsutil/unicode-utils.c index 0bed1c789a..2ade075ad9 100644 --- a/wsutil/unicode-utils.c +++ b/wsutil/unicode-utils.c @@ -8,7 +8,7 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ -#include +#include "config.h" #include "unicode-utils.h" @@ -94,7 +94,7 @@ utf_8to16_snprintf(TCHAR *utf16buf, gint utf16buf_len, const gchar* fmt, ...) gchar* dst; va_start(ap,fmt); - dst = g_strdup_vprintf(fmt, ap); + dst = ws_strdup_vprintf(fmt, ap); va_end(ap); StringCchPrintf(utf16buf, utf16buf_len, _T("%s"), utf_8to16(dst)); diff --git a/wsutil/unicode-utils.h b/wsutil/unicode-utils.h index 9a27703cbd..bdbc48c380 100644 --- a/wsutil/unicode-utils.h +++ b/wsutil/unicode-utils.h @@ -11,9 +11,7 @@ #ifndef __UNICODEUTIL_H__ #define __UNICODEUTIL_H__ -#include "ws_symbol_export.h" - -#include +#include #ifdef _WIN32 #include @@ -49,7 +47,7 @@ const wchar_t * utf_8to16(const char *utf8str); * * @param utf16buf The buffer to return the UTF-16 string in. * @param utf16buf_len The size of the 'utf16buf' parameter - * @param fmt A standard g_printf() format string + * @param fmt A standard printf() format string */ WS_DLL_PUBLIC void utf_8to16_snprintf(TCHAR *utf16buf, gint utf16buf_len, const gchar* fmt, diff --git a/wsutil/win32-utils.c b/wsutil/win32-utils.c index 5973682a7b..49eeccb039 100644 --- a/wsutil/win32-utils.c +++ b/wsutil/win32-utils.c @@ -119,7 +119,7 @@ win32strerror(DWORD error) (LPTSTR)&utf16_message, ERRBUF_SIZE, NULL); if (retval == 0) { /* Failed. */ - tempmsg = g_strdup_printf("Couldn't get error message for error (%lu) (because %lu)", + tempmsg = ws_strdup_printf("Couldn't get error message for error (%lu) (because %lu)", error, GetLastError()); msg = g_intern_string(tempmsg); g_free(tempmsg); @@ -130,13 +130,13 @@ win32strerror(DWORD error) LocalFree(utf16_message); if (utf8_message == NULL) { /* Conversion failed. */ - tempmsg = g_strdup_printf("Couldn't convert error message for error to UTF-8 (%lu) (because %lu)", + tempmsg = ws_strdup_printf("Couldn't convert error message for error to UTF-8 (%lu) (because %lu)", error, GetLastError()); msg = g_intern_string(tempmsg); g_free(tempmsg); return msg; } - tempmsg = g_strdup_printf("%s (%lu)", utf8_message, error); + tempmsg = ws_strdup_printf("%s (%lu)", utf8_message, error); g_free(utf8_message); msg = g_intern_string(tempmsg); g_free(tempmsg); @@ -185,7 +185,7 @@ win32strexception(DWORD exception) if (exceptions[i].code == exception) return exceptions[i].msg; } - g_snprintf(errbuf, (gulong)sizeof errbuf, "Exception 0x%08x", exception); + snprintf(errbuf, (gulong)sizeof errbuf, "Exception 0x%08x", exception); return errbuf; } diff --git a/wsutil/wmem/wmem_interval_tree.c b/wsutil/wmem/wmem_interval_tree.c index 308fc5a4c3..805e70afe7 100644 --- a/wsutil/wmem/wmem_interval_tree.c +++ b/wsutil/wmem/wmem_interval_tree.c @@ -31,7 +31,7 @@ print_range(const void *value) if(!value) { return; } - printf("Range: low=%" G_GUINT64_FORMAT " high=%" G_GUINT64_FORMAT " max_edge=%" G_GUINT64_FORMAT "\n", range->low, range->high, range->max_edge); + printf("Range: low=%" PRIu64 " high=%" PRIu64 " max_edge=%" PRIu64 "\n", range->low, range->high, range->max_edge); } /** diff --git a/wsutil/ws_pipe.c b/wsutil/ws_pipe.c index 7e5a6d601c..678eb4eff0 100644 --- a/wsutil/ws_pipe.c +++ b/wsutil/ws_pipe.c @@ -125,7 +125,7 @@ ws_pipe_create_overlapped_read(HANDLE *read_pipe_handle, HANDLE *write_pipe_hand SECURITY_ATTRIBUTES *sa, DWORD suggested_buffer_size) { HANDLE read_pipe, write_pipe; - guchar *name = g_strdup_printf("\\\\.\\Pipe\\WiresharkWsPipe.%08x.%08x", + guchar *name = ws_strdup_printf("\\\\.\\Pipe\\WiresharkWsPipe.%08x.%08x", GetCurrentProcessId(), InterlockedIncrement(&pipe_serial_number)); gunichar2 *wname = g_utf8_to_utf16(name, -1, NULL, NULL, NULL); diff --git a/wsutil/wsgcrypt.c b/wsutil/wsgcrypt.c index dedb39ea48..caf766af2d 100644 --- a/wsutil/wsgcrypt.c +++ b/wsutil/wsgcrypt.c @@ -11,7 +11,6 @@ */ #include "wsgcrypt.h" -#include "ws_attributes.h" gcry_error_t ws_hmac_buffer(int algo, void *digest, const void *buffer, size_t length, const void *key, size_t keylen) { @@ -96,14 +95,14 @@ size_t rsa_decrypt_inplace(const guint len, guchar* data, gcry_sexp_t pk, gboole /* create mpi representation of encrypted data */ rc = gcry_mpi_scan(&encr_mpi, GCRYMPI_FMT_USG, data, len, NULL); if (rc != 0 ) { - *err = g_strdup_printf("can't convert data to mpi (size %d):%s", len, gcry_strerror(rc)); + *err = ws_strdup_printf("can't convert data to mpi (size %d):%s", len, gcry_strerror(rc)); return 0; } /* put the data into a simple list */ rc = gcry_sexp_build(&s_data, NULL, "(enc-val(rsa(a%m)))", encr_mpi); if (rc != 0) { - *err = g_strdup_printf("can't build encr_sexp:%s", gcry_strerror(rc)); + *err = ws_strdup_printf("can't build encr_sexp:%s", gcry_strerror(rc)); decr_len = 0; goto out; } @@ -112,7 +111,7 @@ size_t rsa_decrypt_inplace(const guint len, guchar* data, gcry_sexp_t pk, gboole rc = gcry_pk_decrypt(&s_plain, s_data, pk); if (rc != 0) { - *err = g_strdup_printf("can't decrypt key:%s", gcry_strerror(rc)); + *err = ws_strdup_printf("can't decrypt key:%s", gcry_strerror(rc)); decr_len = 0; goto out; } @@ -128,14 +127,14 @@ size_t rsa_decrypt_inplace(const guint len, guchar* data, gcry_sexp_t pk, gboole /* compute size requested for plaintext buffer */ rc = gcry_mpi_print(GCRYMPI_FMT_USG, NULL, 0, &decr_len, text); if (rc != 0) { - *err = g_strdup_printf("can't compute decr size:%s", gcry_strerror(rc)); + *err = ws_strdup_printf("can't compute decr size:%s", gcry_strerror(rc)); decr_len = 0; goto out; } /* sanity check on out buffer */ if (decr_len > len) { - *err = g_strdup_printf("decrypted data is too long ?!? (%" G_GSIZE_MODIFIER "u max %d)", decr_len, len); + *err = ws_strdup_printf("decrypted data is too long ?!? (%zu max %d)", decr_len, len); decr_len = 0; goto out; } @@ -143,7 +142,7 @@ size_t rsa_decrypt_inplace(const guint len, guchar* data, gcry_sexp_t pk, gboole /* write plain text to newly allocated buffer */ rc = gcry_mpi_print(GCRYMPI_FMT_USG, data, len, &decr_len, text); if (rc != 0) { - *err = g_strdup_printf("can't print decr data to mpi (size %" G_GSIZE_MODIFIER "u):%s", decr_len, gcry_strerror(rc)); + *err = ws_strdup_printf("can't print decr data to mpi (size %zu):%s", decr_len, gcry_strerror(rc)); decr_len = 0; goto out; } diff --git a/wsutil/wsgcrypt.h b/wsutil/wsgcrypt.h index 493540d64a..1997ffa8c3 100644 --- a/wsutil/wsgcrypt.h +++ b/wsutil/wsgcrypt.h @@ -15,9 +15,7 @@ #ifndef __WSGCRYPT_H__ #define __WSGCRYPT_H__ -#include -#include "ws_symbol_export.h" -#include +#include DIAG_OFF(deprecated-declarations)