Files
OpenCellular/firmware/lib/utility.c
Randall Spangler 7993f257af Reformat to kernel style
No code changes, just reformatting.

BUG=none
BRANCH=none
TEST=make runtests

Change-Id: Id690c8334147970784db5ac54933ad1f5a58dcc1
Reviewed-on: https://gerrit.chromium.org/gerrit/42263
Tested-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Queue: Randall Spangler <rspangler@chromium.org>
2013-01-31 09:38:28 -08:00

28 lines
637 B
C

/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
* Utility functions that need to be built as part of the firmware.
*/
#include "sysincludes.h"
#include "utility.h"
int SafeMemcmp(const void *s1, const void *s2, size_t n) {
const unsigned char *us1 = s1;
const unsigned char *us2 = s2;
int result = 0;
if (0 == n)
return 0;
/*
* Code snippet without data-dependent branch due to Nate Lawson
* (nate@root.org) of Root Labs.
*/
while (n--)
result |= *us1++ ^ *us2++;
return result != 0;
}