-
Notifications
You must be signed in to change notification settings - Fork 12
Description
Some function (like strlen) have their parameters declared as being non-null, so the compiler can warn about it when it knows that a null-argument is passed to it. But of course, the compiler cannot always determine whether a argument is null or not. But it now warns about it, when you check the argument in the implementation. I added a fix for it long time ago, eg. in
86d54fb#diff-0d90af3a410d3fd6d8162e2526179c68988bb7e1140374bf7411d9fbc717e224
However, that seems to be incomplete. The warning is gone, but the check seems to be also gone:
_strlen:
[00000000] 206f 0004 movea.l 4(a7),a0
[00000004] 5288 addq.l #1,a0
[00000006] 2008 move.l a0,d0
.L2:
[00000008] 4a28 ffff tst.b -1(a0)
[0000000c] 6606 bne.s .L7
[0000000e] 91c0 suba.l d0,a0
[00000010] 2008 move.l a0,d0
[00000012] 4e75 rts
.L7:
[00000014] 5288 addq.l #1,a0
[00000016] 60f0 bra.s .L2
Not sure which behaviour is better. It is definitely an application error if a null argument is passed to strlen, and on other systems that will also core-dump. So should be somehow make sure that the NULL check remains intact like it was when using older compiler versions? Or should we remove that check altogether, and let the application crash? If it should remain, i wonder how we can achieve that without messing with the declaration in string.h.