Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
Fix unused result errors in bionic.
Browse files Browse the repository at this point in the history
This lets us use _FORTIFY_SOURCE=2 on the host.

Change-Id: I69f5ff9834bfd595aae6584104bee10c4d8a5eeb
  • Loading branch information
enh-google committed May 13, 2015
1 parent fe77d2d commit c217373
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
3 changes: 2 additions & 1 deletion benchmarks/stdio_benchmark.cpp
Expand Up @@ -16,6 +16,7 @@

#include <stdio.h>
#include <stdio_ext.h>
#include <stdlib.h>

#include <benchmark/Benchmark.h>

Expand Down Expand Up @@ -73,7 +74,7 @@ static void FopenFgetsFclose(int iters, bool no_locking) {
for (int i = 0; i < iters; ++i) {
FILE* fp = fopen("/proc/version", "re");
if (no_locking) __fsetlocking(fp, FSETLOCKING_BYCALLER);
fgets(buf, sizeof(buf), fp);
if (fgets(buf, sizeof(buf), fp) == nullptr) abort();
fclose(fp);
}
}
Expand Down
13 changes: 6 additions & 7 deletions benchmarks/utils.cpp
Expand Up @@ -14,14 +14,16 @@
* limitations under the License.
*/

#include "utils.h"

#include <inttypes.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>

#include <string>

#include "utils.h"
#include <base/stringprintf.h>

int Round(int n) {
int base = 1;
Expand Down Expand Up @@ -72,10 +74,7 @@ std::string PrettyInt(long value, size_t base) {
break;
}
}
char* s = NULL;
asprintf(&s, "%s%" PRId64 "%s", (negative_number ? "-" : ""),
count / kAmountPerUnit[i], kUnitStrings[i]);
std::string result(s);
free(s);
return result;
return android::base::StringPrintf("%s%" PRId64 "%s",
negative_number ? "-" : "",
count / kAmountPerUnit[i], kUnitStrings[i]);
}

0 comments on commit c217373

Please sign in to comment.