X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2Fuuid.c;h=4c1872e7d3a61b0825fe5bbc2d763dd1a2446354;hb=4b798ded2a7fc824d33a28ad8773e89613bbc01b;hp=6f633226129fbe8d6e06a4793d5078b82e994542;hpb=a3307391621135b9521d1a7290db8c274961323a;p=openpts%2Fopenpts.git diff --git a/src/uuid.c b/src/uuid.c index 6f63322..4c1872e 100644 --- a/src/uuid.c +++ b/src/uuid.c @@ -82,6 +82,7 @@ OPENPTS_UUID *newOpenptsUuid() { uuid = xmalloc(sizeof(OPENPTS_UUID)); // BYTE[16] if (uuid == NULL) { + ERROR("no memory"); return NULL; } memset(uuid, 0, sizeof(OPENPTS_UUID)); @@ -97,8 +98,15 @@ OPENPTS_UUID *newOpenptsUuid() { OPENPTS_UUID *newOpenptsUuid2(PTS_UUID *pts_uuid) { OPENPTS_UUID *uuid; + /* check */ + if (pts_uuid == NULL) { + ERROR("null input"); + return NULL; + } + uuid = xmalloc(sizeof(OPENPTS_UUID)); // BYTE[16] if (uuid == NULL) { + ERROR("no memory"); return NULL; } memset(uuid, 0, sizeof(OPENPTS_UUID)); @@ -122,8 +130,15 @@ OPENPTS_UUID *newOpenptsUuidFromFile(char * filename) { OPENPTS_UUID *uuid; int rc; + /* check */ + if (filename == NULL) { + ERROR("null input"); + return NULL; + } + uuid = newOpenptsUuid(); if (uuid == NULL) { + ERROR("no memory"); return NULL; } @@ -175,7 +190,10 @@ void freeOpenptsUuid(OPENPTS_UUID *uuid) { */ int genOpenptsUuid(OPENPTS_UUID *uuid) { /* check */ - ASSERT(NULL != uuid, "uuid is NULL\n"); + if (uuid == NULL) { + ERROR("null input"); + return PTS_FATAL; + } /* check the status */ if (uuid->status == OPENPTS_UUID_EMPTY) { @@ -238,12 +256,12 @@ int readOpenptsUuidFile(OPENPTS_UUID *uuid) { /* check */ if (uuid == NULL) { - ERROR("\n"); - return PTS_INTERNAL_ERROR; + ERROR("null input"); + return PTS_FATAL; } if (uuid->filename == NULL) { - ERROR("\n"); - return PTS_INTERNAL_ERROR; + ERROR("null input"); + return PTS_FATAL; } DEBUG("readOpenptsUuidFile() : %s\n", uuid->filename); @@ -334,12 +352,12 @@ int writeOpenptsUuidFile(OPENPTS_UUID *uuid, int overwrite) { /* check */ if (uuid == NULL) { - ERROR("writeOpenptsUuidFile() - uuid == NULL\n"); - return PTS_INTERNAL_ERROR; + ERROR("null input"); + return PTS_FATAL; } if (uuid->filename == NULL) { - ERROR("writeOpenptsUuidFile() - uuid->filename == NULL\n"); - return PTS_INTERNAL_ERROR; + ERROR("null input\n"); + return PTS_FATAL; } if ((uuid->status != OPENPTS_UUID_FILLED) && (uuid->status != OPENPTS_UUID_CHANGED)) { ERROR("writeOpenptsUuidFile() - uuid->status = %d (!= FILLED or CHANGED)\n", uuid->status);