[PATCH] Add test for mincore syscall
Mike Frysinger
vapier at gentoo.org
Tue Jan 26 20:54:50 UTC 2016
On 26 Jan 2016 13:51, Fei Jie wrote:
> --- /dev/null
> +++ b/tests/mincore.c
> @@ -0,0 +1,43 @@
> +#include "tests.h"
files should have a comment header at the top with a license & description.
> +int main()
should be (void)
> + int PAGESIZE = getpagesize();
don't use upper caps for this var name
> + int global_len = PAGESIZE*2;
spaces around the *
> + char *buf;
> + buf = (char*)malloc(global_len);
the cast is pointless (so delete it), and just merge the two statements.
> + if( MAP_FAILED == (global_pointer = (char *)mmap(NULL,global_len,\
> + PROT_READ|PROT_WRITE|PROT_EXEC,MAP_SHARED,file_desc,0)) ) {
please do not inline assignments into if statements. do the assignment,
then do the if statement checking its value.
drop the \ too.
the leading spacing is wrong ... should be:
if (...
> + unsigned char* global_vec = NULL;
> + global_vec = malloc( (global_len+PAGESIZE-1) / PAGESIZE );
> + if ((res =mincore(global_pointer, global_len, global_vec)) == -1) {
lots of whitespace errors here too
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20160126/04a0f104/attachment.bin>
More information about the Strace-devel
mailing list