OSDN Git Service

FORTIFY_SOURCE: optimize
authorNick Kralevich <nnk@google.com>
Thu, 17 Jan 2013 23:41:33 +0000 (15:41 -0800)
committerNick Kralevich <nnk@google.com>
Thu, 17 Jan 2013 23:41:33 +0000 (15:41 -0800)
commita44e9afdd16105d6f36319cb538666d9cc78435a
tree8606530bcdef438dc305894c805f0713edad5306
parentf3fe19459fd9263e8cc8a413a5313b1ec3cf3975
FORTIFY_SOURCE: optimize

Don't do the fortify_source checks if we can determine, at
compile time, that the provided operation is safe.

This avoids silliness like calling fortify source on things like:

  size_t len = strlen("asdf");
  printf("%d\n", len);

and allows the compiler to optimize this code to:

  printf("%d\n", 4);

Defer to gcc's builtin functions instead of pointing our code
to the libc implementation.

Change-Id: I5e1dcb61946461c4afaaaa983e39f07c7a0df0ae
libc/include/string.h
tests/string_test.cpp