#include static inline long PTR_ERR(const void *ptr) { return (long) ptr; } int main(int argc, const char *argv[]) { printf("sizeof(char) = %lu, sizeof(int) = %lu, sizeof(long) = %lu\n\n", sizeof(char), sizeof(int), sizeof(long)); /*This address is in kernel space, check Documentation/x86/x86_64/mm.txt*/ void *ptr = (void *)0Xffff8900f0000000; printf("ptr = %p, PTR_ERR(ptr) = %lx, (int)(-PTR_ERR(ptr)) = %d\n\n", ptr, PTR_ERR(ptr), (int)(-PTR_ERR(ptr))); if ((int)(-PTR_ERR(ptr)) < 0) printf("That's what the codes want.\n"); else printf("Bug happens!\n"); return 0; }