I have a, rather philosophical, problem with verification of shmat
function output.
Doing this:
void * addr = shmat(shmid, NULL, 0);
if( addr == -1)
{
perror("Uncool stuff");
}
gives me:
warning: comparison between pointer and integer
And this is perfectly ok. Unfortunately, manual says:
Upon success, shmat() returns the address where the segment is attached;
otherwise, -1 is returned and errno is set to indicate the error.
This is quite standard behavior, but how should I handle it? Is if (addr == (void *) -1)
correct? I've read this question and now I'm not really sure, if it would be 100% correct on every possible platform-blah-blah-blah ;-) I haven't found any other reliable sources on that matter.
I believe, that asking about signedness of pointers is a mistake, because pointers are not numbers. But in such case I'm not sure anymore...
Edit: this problem leads us to another question: is char *addr = (char*)shmat(...)
correct? According to answers so far, it is, but if we consider no mmu, etc, etc... Yeah, maybe I'm losing touch with reality here, but I'm curious if there is THE proper way.