mirror of
https://github.com/rsyslog/rsyslog.git
synced 2025-12-13 04:50:41 +01:00
This commit applies the new canonical formatting style using `clang-format` with custom settings (notably 4-space indentation), as part of our shift toward automated formatting normalization. ⚠️ No functional changes are included — only whitespace and layout modifications as produced by `clang-format`. This change is part of the formatting modernization strategy discussed in: https://github.com/rsyslog/rsyslog/issues/5747 Key context: - Formatting is now treated as a disposable view, normalized via tooling. - The `.clang-format` file defines the canonical style. - A fixup script (`devtools/format-code.sh`) handles remaining edge cases. - Formatting commits are added to `.git-blame-ignore-revs` to reduce noise. - Developers remain free to format code however they prefer locally.
36 lines
883 B
C
36 lines
883 B
C
#include <stdlib.h>
|
|
#include <sys/time.h>
|
|
#include <stdio.h>
|
|
#include <time.h>
|
|
|
|
/* one provided by Aaaron Wiebe based on perl's hashing algorithm
|
|
* (so probably pretty generic). Not for excessively large strings!
|
|
*/
|
|
#if defined(__clang__)
|
|
#pragma GCC diagnostic ignored "-Wunknown-attributes"
|
|
#endif
|
|
static unsigned __attribute__((nonnull(1))) int
|
|
#if defined(__clang__)
|
|
__attribute__((no_sanitize("unsigned-integer-overflow")))
|
|
#endif
|
|
hash_from_string(void *k) {
|
|
char *rkey = (char *)k;
|
|
unsigned hashval = 1;
|
|
|
|
while (*rkey) hashval = hashval * 33 + *rkey++;
|
|
|
|
return hashval;
|
|
}
|
|
|
|
int main(int argc, char *argv[]) {
|
|
struct timeval tv;
|
|
gettimeofday(&tv, NULL);
|
|
if (argc != 2) {
|
|
fprintf(stderr, "usage: test_id test-file-name\n");
|
|
exit(1);
|
|
}
|
|
printf("%06ld_%4.4x", tv.tv_usec, hash_from_string(argv[1]));
|
|
|
|
return 0;
|
|
}
|