[PATCH] librt: Add shm_open and shm_unlink + testcase
Bernhard Reutner-Fischer
rep.dot.nop at gmail.com
Thu Feb 26 09:23:22 UTC 2009
On Wed, Feb 11, 2009 at 09:16:04AM +0100, Mikael Lund Jepsen, ICCC wrote:
> Carmelo Amoroso wrote:
>> Mikael Lund Jepsen, ICCC wrote:
> If there are no other objections to the patch, I propose to commit it.
There is licensing information missing from both .c files, please add this
(Copying this from some other spot sounds odd, just reimplement it _cleanly_).
Please remove any trailing whitespace (one in the testcase and in each librt/*.c
there is a 'in case ').
shm_unlink(): remove rc, just return unlink()
Remove the memsets and just set the end of the buffer to '\0' if
len is >= 0.
The argument name should be flagged with attribute_nonnull.
The whole appending of the name to the constant "/dev/shm/" should most
likely just be simplified to some snprintf.
I suggest you just write a new, clean version of those two functions.
In the end they just append a given name to the linux specific path
"/dev/shm/%s" and either open or unlink them, really.
Most of those two function's bodies are a common thing, i.e. should
be in some
static char* get_shm_name(const char*name)
which returns the malloc'ed, 0 terminated path to operate on:
int shm_unlink(const char *name)
{
char *shm_name = get_shm_name(name);
/* Stripped multiple '/' from start; may have set errno properly */
if (shm_name == NULL)
return -1;
return unlink(shm_name);
}
you get the idea.. This functionality sounds like it should fit into
150-250 bytes, fwiw.
More information about the uClibc
mailing list