Skip to content

Commit

Permalink
Fix some printf warnings for CRAN
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroen committed Dec 4, 2023
1 parent 6e64122 commit b28bc2f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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: <https://jeroen.github.io/mongolite/>.
Version: 2.7.2
Version: 2.7.3
Authors@R: c(
person("Jeroen", "Ooms", ,"[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-4035-0289")),
Expand Down
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/gridfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/mongolite.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
#include <bson/bson.h>
#include <mongoc/mongoc.h>

#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);
Expand Down

0 comments on commit b28bc2f

Please sign in to comment.