Skip to content

Instantly share code, notes, and snippets.

@ryandesign
Created November 11, 2011 00:21
Show Gist options
  • Save ryandesign/1356729 to your computer and use it in GitHub Desktop.
Save ryandesign/1356729 to your computer and use it in GitHub Desktop.
Fix mongo-objc-driver warning when compiled with gcc
warning: '0' flag ignored with precision and '%X' printf format
--- Sources/MODBinary.m.orig 2011-11-08 15:00:08.000000000 -0600
+++ Sources/MODBinary.m 2011-11-10 17:54:06.000000000 -0600
@@ -47,7 +47,7 @@
bufferString = malloc(([_data length] * 2) + 1);
count = [_data length];
for(ii = 0; ii < count; ii++) {
- snprintf(bufferString + (ii * 2), 3, "%0.2X", bytes[ii]);
+ snprintf(bufferString + (ii * 2), 3, "%.2X", bytes[ii]);
}
bufferString[(ii * 2) + 1] = 0;
if (pretty) {
--- Sources/MODDBRef.m.orig 2011-11-08 15:00:08.000000000 -0600
+++ Sources/MODDBRef.m 2011-11-10 17:54:06.000000000 -0600
@@ -42,7 +42,7 @@
count = sizeof(_idValue);
bufferString = malloc((count * 2) + 1);
for(ii = 0; ii < count; ii++) {
- snprintf(bufferString + (ii * 2), 3, "%0.2X", bytes[ii]);
+ snprintf(bufferString + (ii * 2), 3, "%.2X", bytes[ii]);
}
bufferString[(ii * 2) + 1] = 0;
result = [NSString stringWithFormat:@"Dbref(\"%@\", \"%@\")", _refValue, bufferString];
@@ -65,7 +65,7 @@
count = sizeof(_idValue);
bufferString = malloc((count * 2) + 1);
for(ii = 0; ii < count; ii++) {
- snprintf(bufferString + (ii * 2), 3, "%0.2X", bytes[ii]);
+ snprintf(bufferString + (ii * 2), 3, "%.2X", bytes[ii]);
}
bufferString[(ii * 2) + 1] = 0;
if (pretty) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment