From b28bc2fbf79de312a16ee74eeef41a270e5722e1 Mon Sep 17 00:00:00 2001 From: Jeroen Ooms Date: Mon, 4 Dec 2023 16:47:49 +0100 Subject: [PATCH] Fix some printf warnings for CRAN --- DESCRIPTION | 2 +- NEWS | 3 +++ src/client.c | 5 +++-- src/gridfs.c | 4 ++-- src/mongolite.h | 3 ++- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index b52a2e86..3fafe236 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -5,7 +5,7 @@ Description: High-performance MongoDB client based on 'mongo-c-driver' and 'json Includes support for aggregation, indexing, map-reduce, streaming, encryption, enterprise authentication, and GridFS. The online user manual provides an overview of the available methods in the package: . -Version: 2.7.2 +Version: 2.7.3 Authors@R: c( person("Jeroen", "Ooms", ,"jeroen@berkeley.edu", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-4035-0289")), diff --git a/NEWS b/NEWS index dcf098e3..fa895c8f 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +2.7.3 + - Fix some printf warnings for CRAN + 2.7.2 - Fix another -Wstrict-prototypes warning (mac only) - Internally use sha1 instead of md5 keys for caching diff --git a/src/client.c b/src/client.c index e62be14f..073050c6 100644 --- a/src/client.c +++ b/src/client.c @@ -24,9 +24,10 @@ SEXP R_mongo_client_new(SEXP uri_string, SEXP pem_file, SEXP pem_pwd, SEXP ca_fi SEXP ca_dir, SEXP crl_file, SEXP allow_invalid_hostname, SEXP weak_cert_validation) { bson_error_t err; - mongoc_uri_t *uri = mongoc_uri_new_with_error (Rf_translateCharUTF8(STRING_ELT(uri_string, 0)), &err); + const char *urlstr = Rf_translateCharUTF8(STRING_ELT(uri_string, 0)); + mongoc_uri_t *uri = mongoc_uri_new_with_error (urlstr, &err); if (!uri) - Rf_error("failed to parse URI: %s (%s)", uri_string, err.message); + Rf_error("failed to parse URI: %s (%s)", urlstr, err.message); /* openssl is too old on Solaris, skip cert validation */ #if defined(__sun) diff --git a/src/gridfs.c b/src/gridfs.c index a0383bbd..72b02d36 100644 --- a/src/gridfs.c +++ b/src/gridfs.c @@ -60,7 +60,7 @@ static mongoc_gridfs_file_t * find_single_file(SEXP ptr_fs, SEXP name){ mongoc_gridfs_find_one_by_filename (fs, get_string(name), &err) : mongoc_gridfs_find_one_with_opts(fs, r2bson(name), NULL, &err); if(file == NULL) - stop("File not found. %s", err.message); + stopf("File not found. %s", err.message); return file; } @@ -137,7 +137,7 @@ SEXP R_mongo_gridfs_download(SEXP ptr_fs, SEXP name, SEXP path){ char buf[4096]; FILE * fp = fopen(get_string(path), "wb"); if(!fp) - stop("Failed to open file %s", get_string(path)); + stopf("Failed to open file %s", get_string(path)); for(;;) { int nbytes = mongoc_stream_read(stream, buf, 4096, -1, 0); diff --git a/src/mongolite.h b/src/mongolite.h index b078da1e..fc4523eb 100644 --- a/src/mongolite.h +++ b/src/mongolite.h @@ -5,7 +5,8 @@ #include #include -#define stop(...) Rf_errorcall(R_NilValue, __VA_ARGS__) +#define stop(str) Rf_errorcall(R_NilValue, "%s", str) +#define stopf(...) Rf_errorcall(R_NilValue, __VA_ARGS__) SEXP mkStringUTF8(const char* str); SEXP mkRaw(const unsigned char *buf, int len);