[PATCH 3/3] powerpc/kprobes: Check return value of patch_instruction()
Naveen N. Rao
naveen.n.rao at linux.vnet.ibm.com
Sat Apr 25 05:38:07 AEST 2020
Steven Rostedt wrote:
> On Fri, 24 Apr 2020 23:56:25 +0530
> "Naveen N. Rao" <naveen.n.rao at linux.vnet.ibm.com> wrote:
>
>> > #define PATCH_INSN(addr, instr) \
>> > ({
>> > int rc = patch_instruction((unsigned int *)(addr), instr); \
>> > if (rc) \
>> > pr_err("%s:%d Error patching instruction at 0x%pK (%pS): %d\n", \
>> > __func__, __LINE__, \
>> > (void *)(addr), (void *)(addr), rc); \
>> > rc; \
>> > })
>> >
>> >
>> > Then you can just do:
>> >
>> > ret = PATCH_INSN(...);
>> > if (ret)
>> > return ret;
>> >
>> > in the code.
>>
>> That's really nice. However, in this case, I guess I can simply use an
>> inline function? The primary reason I used the macro was for including a
>> 'return' statement in it.
>
> I thought the primary reason was the __func__, __LINE__ which wont work as
> expected as an inline.
Ugh, you're right indeed. I clearly didn't think it through. :facepalm:
I'll use this variant.
Regards,
Naveen
More information about the Linuxppc-dev
mailing list