Files
RedBear-OS/local/recipes/dev/libclc/source/clang/test/Analysis/fixed-address-notes.c
T
vasilito cb424d7448 build: static patch-sanity linter (shift-left the malformed-patch class)
verify-patch-sanity.py validates every active recipe .patch has internally-
consistent hunk line counts — catching the 'malformed patch at line N' failure
at commit/CI/preflight time instead of hours into a cook. This cycle hit that
class three times (qtwaylandscanner, sddm, xwayland), each only discovered when
cookbook tried to apply the patch.

Running it across the repo found 29 latent malformed patches (validated against
GNU patch: e.g. relibc/P3-sysv-ipc reproduces 'malformed patch at line 22').
They were harmless only because they sit in vendored recipes (baked, not re-
applied) — but would fail on any version-bump re-derivation. --fix recounts the
hunk headers (body untouched) and repaired all 29.

Wired into build-preflight.sh (Phase 1.0D) and redbear-ci.yml, with a unit test
(test-patch-sanity.sh). Skips archived/legacy trees and unvalidatable formats
(empty placeholders, bare-@@ git hunks).
2026-08-01 05:13:02 +03:00

53 lines
2.0 KiB
C

// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=text -verify %s
extern char *something();
void test1() {
int *p;
p = (int *)22; // expected-note{{Pointer value of (int *)22 stored to 'p'}}
*p = 2; // expected-warning{{Dereference of a fixed address (loaded from variable 'p')}} \
// expected-note{{Dereference of a fixed address (loaded from variable 'p')}}
}
void test2_1(int *p) {
*p = 1; // expected-warning{{Dereference of a fixed address (loaded from variable 'p')}} \
// expected-note{{Dereference of a fixed address (loaded from variable 'p')}}
}
void test2() {
int *p = (int *)11; // expected-note{{'p' initialized to (int *)11}}
test2_1(p); // expected-note{{Passing pointer value (int *)11 via 1st parameter 'p'}} \
// expected-note{{Calling 'test2_1'}}
}
struct test3_s {
int a;
};
void test3() {
struct test3_s *x;
unsigned long long val = 1111111; // expected-note{{'val' initialized to 1111111}}
x = (struct test3_s *)val; // expected-note{{Pointer value of (struct test3_s *)1111111 stored to 'x'}}
x->a = 3; // expected-warning{{Access to field 'a' results in a dereference of a fixed address (loaded from variable 'x')}} \
// expected-note{{Access to field 'a' results in a dereference of a fixed address (loaded from variable 'x')}}
}
char *test4_1() {
char *ret;
ret = something(); // expected-note{{Value assigned to 'ret'}}
if (ret == (char *)-1) // expected-note{{Assuming the condition is true}} \
// expected-note{{Taking true branch}}
return ret; // expected-note{{Returning pointer (loaded from 'ret')}}
return 0;
}
void test4() {
char *x;
x = test4_1(); // expected-note{{Calling 'test4_1'}} \
// expected-note{{Returning from 'test4_1'}} \
// expected-note{{Pointer value of (char *)-1 stored to 'x'}}
*x = 3; // expected-warning{{Dereference of a fixed address (loaded from variable 'x')}} \
// expected-note{{Dereference of a fixed address (loaded from variable 'x')}}
}