aboutsummaryrefslogtreecommitdiffstats
path: root/src/string/strchr.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2015-09-01 21:07:54 +0200
committerMattias Andrée <maandree@operamail.com>2015-09-01 21:07:54 +0200
commitac044784a6ce64ff15610d4b70750065a7f01b80 (patch)
tree8ac8629c0089099f21be9107a5d3779963d33ca0 /src/string/strchr.c
parentadd memfrob (diff)
downloadslibc-ac044784a6ce64ff15610d4b70750065a7f01b80.tar.gz
slibc-ac044784a6ce64ff15610d4b70750065a7f01b80.tar.bz2
slibc-ac044784a6ce64ff15610d4b70750065a7f01b80.tar.xz
start on makefile and fixing warnings and errors
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--src/string/strchr.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/string/strchr.c b/src/string/strchr.c
index 21345d4..2b49c2e 100644
--- a/src/string/strchr.c
+++ b/src/string/strchr.c
@@ -16,7 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <string.h>
-#include <stddef.h>
+
+
+# pragma GCC diagnostic ignored "-Wdiscarded-qualifiers"
@@ -31,9 +33,10 @@
*/
void* memchr(const void* segment, int c, size_t size)
{
+ char* s = segment;
while (size--)
- if (*segment++ == c)
- return segment - 1;
+ if (*s++ == c)
+ return s - 1;
return NULL;
}
@@ -50,9 +53,10 @@ void* memchr(const void* segment, int c, size_t size)
*/
void* rawmemchr(const void* segment, int c)
{
+ char* s = segment;
for (;;)
- if (*segment++ == c)
- return segment - 1;
+ if (*s++ == c)
+ return s - 1;
}
@@ -71,9 +75,10 @@ void* rawmemchr(const void* segment, int c)
*/
void* memrchr(const void* segment, int c, size_t size)
{
+ char* s = segment;
while (size--)
- if (segment[size] == c)
- return segment + size;
+ if (s[size] == c)
+ return s + size;
return NULL;
}