Fix strcmp_static semantics to match the standard strcmp

This commit is contained in:
Michał Kowalczyk
2019-10-02 22:21:11 +02:00
parent 0612bab52b
commit df6c52dff8
22 changed files with 83 additions and 84 deletions
+1 -1
View File
@@ -330,7 +330,7 @@ static bool is_sgx_pal(void) {
if (!atomic_read(&inited)) {
/* Ensure that is_sgx_pal is updated before initialized */
atomic_set(&sgx_pal, strcmp_static(PAL_CB(host_type), "Linux-SGX"));
atomic_set(&sgx_pal, !strcmp_static(PAL_CB(host_type), "Linux-SGX"));
MB();
atomic_set(&inited, 1);
}
+10 -10
View File
@@ -160,7 +160,7 @@ static int dev_random_hstat(struct shim_handle* hdl, struct stat* stat) {
}
static int search_dev_driver(const char* name, struct shim_dev_ops* ops) {
if (strcmp_static(name, "null") || strcmp_static(name, "tty")) {
if (!strcmp_static(name, "null") || !strcmp_static(name, "tty")) {
if (ops)
ops->read = &dev_null_read;
null_dev:
@@ -174,13 +174,13 @@ static int search_dev_driver(const char* name, struct shim_dev_ops* ops) {
return 0;
}
if (strcmp_static(name, "zero")) {
if (!strcmp_static(name, "zero")) {
if (ops)
ops->read = &dev_zero_read;
goto null_dev;
}
if (strcmp_static(name, "random")) {
if (!strcmp_static(name, "random")) {
if (ops)
ops->read = &dev_random_read;
random_dev:
@@ -192,14 +192,14 @@ static int search_dev_driver(const char* name, struct shim_dev_ops* ops) {
return 0;
}
if (strcmp_static(name, "urandom")) {
if (!strcmp_static(name, "urandom")) {
if (ops)
ops->read = &dev_urandom_read;
goto random_dev;
}
if (strcmp_static(name, "stdin") || strcmp_static(name, "stdout") ||
strcmp_static(name, "stderr"))
if (!strcmp_static(name, "stdin") || !strcmp_static(name, "stdout") ||
!strcmp_static(name, "stderr"))
return -EISLINK;
return -ENOENT;
@@ -421,18 +421,18 @@ static off_t dev_poll(struct shim_handle* hdl, int poll_type) {
static int dev_follow_link(struct shim_dentry* dent, struct shim_qstr* link) {
const char* name = qstrgetstr(&dent->rel_path);
if (strcmp_static(name, "stdin")) {
if (!strcmp_static(name, "stdin")) {
qstrsetstr(link, "/proc/self/0", static_strlen("/proc/self/0"));
return 0;
} else if (strcmp_static(name, "stdout")) {
} else if (!strcmp_static(name, "stdout")) {
qstrsetstr(link, "/proc/self/1", static_strlen("/proc/self/1"));
return 0;
} else if (strcmp_static(name, "stderr")) {
} else if (!strcmp_static(name, "stderr")) {
qstrsetstr(link, "/proc/self/2", static_strlen("/proc/self/2"));
return 0;
}
if (strcmp_static(name, "null") || strcmp_static(name, "zero"))
if (!strcmp_static(name, "null") || !strcmp_static(name, "zero"))
return -ENOTLINK;
return -ENOENT;
+2 -2
View File
@@ -163,7 +163,7 @@ long int glibc_option (const char * opt)
{
char cfg[CONFIG_MAX];
if (strcmp_static(opt, "heap_size")) {
if (!strcmp_static(opt, "heap_size")) {
ssize_t ret = get_config(root_config, "glibc.heap_size", cfg, CONFIG_MAX);
if (ret <= 0) {
debug("no glibc option: %s (err=%ld)\n", opt, ret);
@@ -727,7 +727,7 @@ noreturn void* shim_init (int argc, void * args)
debug("shim loaded at %p, ready to initialize\n", &__load_address);
if (argc && argv[0][0] == '-') {
if (strcmp_static(argv[0], "-resume") && argc >= 2) {
if (!strcmp_static(argv[0], "-resume") && argc >= 2) {
const char * filename = *(argv + 1);
argc -= 2;
argv += 2;
+4 -4
View File
@@ -396,8 +396,8 @@ struct parser_table {
};
static inline int is_pointer(const char* type) {
return type[strlen(type) - 1] == '*' || strcmp_static(type, "long") ||
strcmp_static(type, "unsigned long");
return type[strlen(type) - 1] == '*' || !strcmp_static(type, "long") ||
!strcmp_static(type, "unsigned long");
}
#define PRINTF(fmt, ...) \
@@ -441,7 +441,7 @@ static inline void parse_integer_arg(va_list ap) {
static inline void parse_syscall_args(va_list ap) {
const char* arg_type = va_arg(ap, const char*);
if (strcmp_static(arg_type, "const char *") || strcmp_static(arg_type, "const char*"))
if (!strcmp_static(arg_type, "const char *") || !strcmp_static(arg_type, "const char*"))
parse_string_arg(ap);
else if (is_pointer(arg_type))
parse_pointer_arg(ap);
@@ -452,7 +452,7 @@ static inline void parse_syscall_args(va_list ap) {
static inline void skip_syscall_args(va_list ap) {
const char* arg_type = va_arg(ap, const char*);
if (strcmp_static(arg_type, "const char *") || strcmp_static(arg_type, "const char*"))
if (!strcmp_static(arg_type, "const char *") || !strcmp_static(arg_type, "const char*"))
va_arg(ap, const char*);
else if (is_pointer(arg_type))
va_arg(ap, void*);
+1 -1
View File
@@ -468,7 +468,7 @@ err:
SAVE_PROFILE_INTERVAL(open_file_for_exec);
#if EXECVE_RTLD == 1
if (!strcmp_static(PAL_CB(host_type), "Linux-SGX")) {
if (strcmp_static(PAL_CB(host_type), "Linux-SGX")) {
int is_last = check_last_thread(cur_thread) == 0;
if (is_last) {
debug("execve() in the same process\n");
+7 -8
View File
@@ -118,24 +118,23 @@ void *malloc(size_t size);
void free(void *ptr);
void *calloc(size_t nmemb, size_t size);
/* Some useful macro */
/* force failure if str is not a static string */
#define force_static(str) ("" str "")
#define force_literal_cstr(str) ("" str "")
/* check if the var is exactly the same as the static string */
#define strcmp_static(var, str) \
(!memcmp((var), force_static(str), static_strlen(force_static(str)) + 1))
(memcmp(var, force_literal_cstr(str), static_strlen(force_literal_cstr(str)) + 1))
/* check if the var starts with the static string */
#define strpartcmp_static(var, str) \
(!memcmp((var), force_static(str), static_strlen(force_static(str))))
(!memcmp(var, force_literal_cstr(str), static_strlen(force_literal_cstr(str))))
/* copy static string and return the address of the null end (null if the dest
* is not large enough).*/
#define strcpy_static(var, str, max) \
(static_strlen(force_static(str)) + 1 > (max) ? NULL : \
memcpy((var), force_static(str), static_strlen(force_static(str)) + 1) + \
static_strlen(force_static(str)))
#define strcpy_static(var, str, max) \
(static_strlen(force_literal_cstr(str)) + 1 > (max) ? NULL : \
memcpy((var), force_literal_cstr(str), static_strlen(force_literal_cstr(str)) + 1) + \
static_strlen(force_literal_cstr(str)))
/* Copy a fixed size array. */
#define COPY_ARRAY(dst, src) \
+5 -5
View File
@@ -186,9 +186,9 @@ static void set_debug_type (void)
PAL_HANDLE handle = NULL;
if (strcmp_static(cfgbuf, "inline")) {
if (!strcmp_static(cfgbuf, "inline")) {
ret = _DkStreamOpen(&handle, "dev:tty", PAL_ACCESS_RDWR, 0, 0, 0);
} else if (strcmp_static(cfgbuf, "file")) {
} else if (!strcmp_static(cfgbuf, "file")) {
ret = get_config(pal_state.root_config, "loader.debug_file",
cfgbuf, CONFIG_MAX);
if (ret <= 0)
@@ -198,7 +198,7 @@ static void set_debug_type (void)
PAL_ACCESS_RDWR,
PAL_SHARE_OWNER_R|PAL_SHARE_OWNER_W,
PAL_CREATE_TRY, 0);
} else if (strcmp_static(cfgbuf, "none")) {
} else if (!strcmp_static(cfgbuf, "none")) {
ret = 0;
} else {
INIT_FAIL(PAL_ERROR_INVAL, "unknown debug type");
@@ -357,11 +357,11 @@ noreturn void pal_main (
size_t exec_strlen = manifest_strlen - 9;
int success = 0;
// Try .manifest
if (strcmp_static(&manifest_uri[exec_strlen], ".manifest")) {
if (!strcmp_static(&manifest_uri[exec_strlen], ".manifest")) {
success = 1;
} else {
exec_strlen -= 4;
if (strcmp_static(&manifest_uri[exec_strlen], ".manifest.sgx")) {
if (!strcmp_static(&manifest_uri[exec_strlen], ".manifest.sgx")) {
success = 1;
}
}
+3 -3
View File
@@ -303,7 +303,7 @@ static int pipe_private (PAL_HANDLE * handle, int options)
static int pipe_open (PAL_HANDLE *handle, const char * type, const char * uri,
int access, int share, int create, int options)
{
if (strcmp_static(type, "pipe") && !*uri)
if (!strcmp_static(type, "pipe") && !*uri)
return pipe_private(handle, options);
char * endptr;
@@ -314,10 +314,10 @@ static int pipe_open (PAL_HANDLE *handle, const char * type, const char * uri,
options = HOST_OPTIONS(options & PAL_OPTION_MASK);
if (strcmp_static(type, "pipe.srv"))
if (!strcmp_static(type, "pipe.srv"))
return pipe_listen(handle, pipeid, options);
if (strcmp_static(type, "pipe"))
if (!strcmp_static(type, "pipe"))
return pipe_connect(handle, pipeid, options);
return -PAL_ERROR_INVAL;
+4 -4
View File
@@ -544,10 +544,10 @@ static int tcp_open (PAL_HANDLE *handle, const char * type, const char * uri,
char uri_buf[PAL_SOCKADDR_SIZE];
memcpy(uri_buf, uri, uri_len);
if (strcmp_static(type, "tcp.srv"))
if (!strcmp_static(type, "tcp.srv"))
return tcp_listen(handle, uri_buf, options);
if (strcmp_static(type, "tcp"))
if (!strcmp_static(type, "tcp"))
return tcp_connect(handle, uri_buf, options);
return -PAL_ERROR_NOTSUPPORT;
@@ -766,10 +766,10 @@ static int udp_open (PAL_HANDLE *hdl, const char * type, const char * uri,
memcpy(buf, uri, len + 1);
options &= PAL_OPTION_MASK;
if (strcmp_static(type, "udp.srv"))
if (!strcmp_static(type, "udp.srv"))
return udp_bind(hdl, buf, options);
if (strcmp_static(type, "udp"))
if (!strcmp_static(type, "udp"))
return udp_connect(hdl, buf, options);
return -PAL_ERROR_NOTSUPPORT;
+4 -4
View File
@@ -115,7 +115,7 @@ static int open_standard_term(PAL_HANDLE* handle, const char* param, int access)
/* 'open' operation for terminal stream */
static int term_open(PAL_HANDLE* handle, const char* type, const char* uri, int access, int share,
int create, int options) {
if (!strcmp_static(type, "tty"))
if (strcmp_static(type, "tty"))
return -PAL_ERROR_INVAL;
if (!WITHIN_MASK(share, PAL_SHARE_MASK) || !WITHIN_MASK(create, PAL_CREATE_MASK) ||
@@ -151,7 +151,7 @@ static int term_close(PAL_HANDLE handle) {
static int term_attrquery(const char* type, const char* uri, PAL_STREAM_ATTR* attr) {
__UNUSED(uri);
if (!strcmp_static(type, "tty"))
if (strcmp_static(type, "tty"))
return -PAL_ERROR_INVAL;
attr->handle_type = pal_type_dev;
@@ -218,7 +218,7 @@ static int64_t char_write(PAL_HANDLE handle, uint64_t offset, uint64_t size, con
/* 'open' operation for device streams */
static int dev_open(PAL_HANDLE* handle, const char* type, const char* uri, int access, int share,
int create, int options) {
if (!strcmp_static(type, "dev"))
if (strcmp_static(type, "dev"))
return -PAL_ERROR_INVAL;
struct handle_ops* ops = NULL;
@@ -327,7 +327,7 @@ static int dev_flush(PAL_HANDLE handle) {
/* 'attrquery' operation for device streams */
static int dev_attrquery(const char* type, const char* uri, PAL_STREAM_ATTR* attr) {
if (!strcmp_static(type, "dev"))
if (strcmp_static(type, "dev"))
return -PAL_ERROR_INVAL;
struct handle_ops* ops = NULL;
+5 -5
View File
@@ -45,7 +45,7 @@ typedef __kernel_pid_t pid_t;
/* 'open' operation for file streams */
static int file_open(PAL_HANDLE* handle, const char* type, const char* uri, int access, int share,
int create, int options) {
if (!strcmp_static(type, "file"))
if (strcmp_static(type, "file"))
return -PAL_ERROR_INVAL;
/* try to do the real open */
int fd = ocall_open(uri, access | create | options, share);
@@ -314,7 +314,7 @@ static inline void file_attrcopy(PAL_STREAM_ATTR* attr, struct stat* stat) {
/* 'attrquery' operation for file streams */
static int file_attrquery(const char* type, const char* uri, PAL_STREAM_ATTR* attr) {
if (!strcmp_static(type, "file") && !strcmp_static(type, "dir"))
if (strcmp_static(type, "file") && strcmp_static(type, "dir"))
return -PAL_ERROR_INVAL;
/* try to do the real open */
int fd = ocall_open(uri, 0, 0);
@@ -356,7 +356,7 @@ static int file_attrsetbyhdl(PAL_HANDLE handle, PAL_STREAM_ATTR* attr) {
}
static int file_rename(PAL_HANDLE handle, const char* type, const char* uri) {
if (!strcmp_static(type, "file"))
if (strcmp_static(type, "file"))
return -PAL_ERROR_INVAL;
char* tmp = strdup(uri);
@@ -418,7 +418,7 @@ struct handle_ops file_ops = {
ended with slashes. dir_open will be called by file_open. */
static int dir_open(PAL_HANDLE* handle, const char* type, const char* uri, int access, int share,
int create, int options) {
if (!strcmp_static(type, "dir"))
if (strcmp_static(type, "dir"))
return -PAL_ERROR_INVAL;
if (!WITHIN_MASK(access, PAL_ACCESS_MASK))
return -PAL_ERROR_INVAL;
@@ -567,7 +567,7 @@ static int dir_delete(PAL_HANDLE handle, int access) {
}
static int dir_rename(PAL_HANDLE handle, const char* type, const char* uri) {
if (!strcmp_static(type, "dir"))
if (strcmp_static(type, "dir"))
return -PAL_ERROR_INVAL;
char* tmp = strdup(uri);
+3 -3
View File
@@ -157,7 +157,7 @@ static int pipe_open(PAL_HANDLE* handle, const char* type, const char* uri, int
!WITHIN_MASK(create, PAL_CREATE_MASK) || !WITHIN_MASK(options, PAL_OPTION_MASK))
return -PAL_ERROR_INVAL;
if (strcmp_static(type, "pipe") && !*uri)
if (!strcmp_static(type, "pipe") && !*uri)
return pipe_private(handle, options);
char* endptr;
@@ -166,10 +166,10 @@ static int pipe_open(PAL_HANDLE* handle, const char* type, const char* uri, int
if (*endptr)
return -PAL_ERROR_INVAL;
if (strcmp_static(type, "pipe.srv"))
if (!strcmp_static(type, "pipe.srv"))
return pipe_listen(handle, pipeid, options);
if (strcmp_static(type, "pipe"))
if (!strcmp_static(type, "pipe"))
return pipe_connect(handle, pipeid, options);
return -PAL_ERROR_INVAL;
+2 -2
View File
@@ -98,7 +98,7 @@ void _DkDebugAddMap (struct link_map * map)
ElfW(Addr) text_addr = 0;
for (ElfW(Shdr) * s = shdr ; s < shdrend ; s++)
if (strcmp_static(shstrtab + s->sh_name, ".text")) {
if (!strcmp_static(shstrtab + s->sh_name, ".text")) {
text_addr = map->l_addr + s->sh_addr;
break;
}
@@ -117,7 +117,7 @@ void _DkDebugAddMap (struct link_map * map)
for (ElfW(Shdr) * s = shdr ; s < shdrend ; s++) {
if (!s->sh_name || !s->sh_addr)
continue;
if (strcmp_static(shstrtab + s->sh_name, ".text"))
if (!strcmp_static(shstrtab + s->sh_name, ".text"))
continue;
if (s->sh_type == SHT_NULL)
continue;
+4 -4
View File
@@ -447,10 +447,10 @@ static int tcp_open(PAL_HANDLE* handle, const char* type, const char* uri, int a
char uri_buf[PAL_SOCKADDR_SIZE];
memcpy(uri_buf, uri, uri_len);
if (strcmp_static(type, "tcp.srv"))
if (!strcmp_static(type, "tcp.srv"))
return tcp_listen(handle, uri_buf, options);
if (strcmp_static(type, "tcp"))
if (!strcmp_static(type, "tcp"))
return tcp_connect(handle, uri_buf, options);
return -PAL_ERROR_NOTSUPPORT;
@@ -608,10 +608,10 @@ static int udp_open(PAL_HANDLE* hdl, const char* type, const char* uri, int acce
memcpy(buf, uri, len + 1);
if (strcmp_static(type, "udp.srv"))
if (!strcmp_static(type, "udp.srv"))
return udp_bind(hdl, buf, options);
if (strcmp_static(type, "udp"))
if (!strcmp_static(type, "udp"))
return udp_connect(hdl, buf, options);
return -PAL_ERROR_NOTSUPPORT;
+4 -4
View File
@@ -450,7 +450,7 @@ int initialize_enclave (struct pal_enclave * enclave)
void * data = NULL;
if (strcmp_static(areas[i].desc, "tls")) {
if (!strcmp_static(areas[i].desc, "tls")) {
data = (void *) INLINE_SYSCALL(mmap, 6, NULL, areas[i].size,
PROT_READ|PROT_WRITE,
MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
@@ -484,7 +484,7 @@ int initialize_enclave (struct pal_enclave * enclave)
}
gs->thread = NULL;
}
} else if (strcmp_static(areas[i].desc, "tcs")) {
} else if (!strcmp_static(areas[i].desc, "tcs")) {
data = (void *) INLINE_SYSCALL(mmap, 6, NULL, areas[i].size,
PROT_READ|PROT_WRITE,
MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
@@ -793,7 +793,7 @@ static int load_enclave (struct pal_enclave * enclave,
#ifdef DEBUG
size_t env_i = 0;
while (env_i < env_size) {
if (strcmp_static(&env[env_i], "IN_GDB=1")) {
if (!strcmp_static(&env[env_i], "IN_GDB=1")) {
SGX_DBG(DBG_I, "[ Running under GDB ]\n");
pal_sec->in_gdb = true;
} else if (strpartcmp_static(&env[env_i], "LD_PRELOAD=")) {
@@ -983,7 +983,7 @@ int main (int argc, char ** argv, char ** envp)
if (!argc)
goto usage;
if (strcmp_static(argv[0], "file:")) {
if (!strcmp_static(argv[0], "file:")) {
exec_uri = alloc_concat(argv[0], -1, NULL, -1);
} else {
exec_uri = alloc_concat("file:", -1, argv[0], -1);
+4 -4
View File
@@ -113,7 +113,7 @@ static int open_standard_term(PAL_HANDLE* handle, const char* param, int access)
/* 'open' operation for terminal stream */
static int term_open(PAL_HANDLE* handle, const char* type, const char* uri, int access, int share,
int create, int options) {
if (!strcmp_static(type, "tty"))
if (strcmp_static(type, "tty"))
return -PAL_ERROR_INVAL;
if (!WITHIN_MASK(share, PAL_SHARE_MASK) || !WITHIN_MASK(create, PAL_CREATE_MASK) ||
@@ -150,7 +150,7 @@ static int term_close(PAL_HANDLE handle) {
static int term_attrquery(const char* type, const char* uri, PAL_STREAM_ATTR* attr) {
__UNUSED(uri);
if (!strcmp_static(type, "tty"))
if (strcmp_static(type, "tty"))
return -PAL_ERROR_INVAL;
attr->handle_type = pal_type_dev;
@@ -219,7 +219,7 @@ static int64_t char_write(PAL_HANDLE handle, uint64_t offset, uint64_t size, con
/* 'open' operation for device streams */
static int dev_open(PAL_HANDLE* handle, const char* type, const char* uri, int access, int share,
int create, int options) {
if (!strcmp_static(type, "dev"))
if (strcmp_static(type, "dev"))
return -PAL_ERROR_INVAL;
struct handle_ops* ops = NULL;
@@ -356,7 +356,7 @@ static int dev_flush(PAL_HANDLE handle) {
/* 'attrquery' operation for device streams */
static int dev_attrquery(const char* type, const char* uri, PAL_STREAM_ATTR* attr) {
if (!strcmp_static(type, "dev"))
if (strcmp_static(type, "dev"))
return -PAL_ERROR_INVAL;
struct handle_ops* ops = NULL;
+5 -5
View File
@@ -41,7 +41,7 @@ typedef __kernel_pid_t pid_t;
static int file_open (PAL_HANDLE * handle, const char * type, const char * uri,
int access, int share, int create, int options)
{
if (!strcmp_static(type, "file"))
if (strcmp_static(type, "file"))
return -PAL_ERROR_INVAL;
/* try to do the real open */
@@ -235,7 +235,7 @@ file_attrcopy (PAL_STREAM_ATTR * attr, struct stat * stat)
static int file_attrquery (const char * type, const char * uri,
PAL_STREAM_ATTR * attr)
{
if (!strcmp_static(type, "file") && !strcmp_static(type, "dir"))
if (strcmp_static(type, "file") && strcmp_static(type, "dir"))
return -PAL_ERROR_INVAL;
struct stat stat_buf;
@@ -281,7 +281,7 @@ static int file_attrsetbyhdl (PAL_HANDLE handle,
static int file_rename (PAL_HANDLE handle, const char * type,
const char * uri)
{
if (!strcmp_static(type, "file"))
if (strcmp_static(type, "file"))
return -PAL_ERROR_INVAL;
char* tmp = strdup(uri);
@@ -347,7 +347,7 @@ struct handle_ops file_ops = {
static int dir_open (PAL_HANDLE * handle, const char * type, const char * uri,
int access, int share, int create, int options)
{
if (!strcmp_static(type, "dir"))
if (strcmp_static(type, "dir"))
return -PAL_ERROR_INVAL;
if (!WITHIN_MASK(access, PAL_ACCESS_MASK))
return -PAL_ERROR_INVAL;
@@ -528,7 +528,7 @@ static int dir_delete (PAL_HANDLE handle, int access)
static int dir_rename (PAL_HANDLE handle, const char * type,
const char * uri)
{
if (!strcmp_static(type, "dir"))
if (strcmp_static(type, "dir"))
return -PAL_ERROR_INVAL;
char* tmp = strdup(uri);
+1 -1
View File
@@ -34,7 +34,7 @@
int gipc_open (PAL_HANDLE * handle, const char * type, const char * uri,
int access, int share, int create, int options)
{
if (!strcmp_static(type, "gipc"))
if (strcmp_static(type, "gipc"))
return -PAL_ERROR_INVAL;
if (!WITHIN_MASK(access, PAL_ACCESS_MASK) ||
+3 -3
View File
@@ -287,7 +287,7 @@ static int pipe_open(PAL_HANDLE* handle, const char* type, const char* uri, int
!WITHIN_MASK(create, PAL_CREATE_MASK) || !WITHIN_MASK(options, PAL_OPTION_MASK))
return -PAL_ERROR_INVAL;
if (strcmp_static(type, "pipe") && !*uri)
if (!strcmp_static(type, "pipe") && !*uri)
return pipe_private(handle, options);
char* endptr;
@@ -296,10 +296,10 @@ static int pipe_open(PAL_HANDLE* handle, const char* type, const char* uri, int
if (*endptr)
return -PAL_ERROR_INVAL;
if (strcmp_static(type, "pipe.srv"))
if (!strcmp_static(type, "pipe.srv"))
return pipe_listen(handle, pipeid, options);
if (strcmp_static(type, "pipe"))
if (!strcmp_static(type, "pipe"))
return pipe_connect(handle, pipeid, options);
return -PAL_ERROR_INVAL;
+4 -4
View File
@@ -537,10 +537,10 @@ static int tcp_open(PAL_HANDLE* handle, const char* type, const char* uri, int a
char uri_buf[PAL_SOCKADDR_SIZE];
memcpy(uri_buf, uri, uri_len);
if (strcmp_static(type, "tcp.srv"))
if (!strcmp_static(type, "tcp.srv"))
return tcp_listen(handle, uri_buf, options);
if (strcmp_static(type, "tcp"))
if (!strcmp_static(type, "tcp"))
return tcp_connect(handle, uri_buf, options);
return -PAL_ERROR_NOTSUPPORT;
@@ -752,10 +752,10 @@ static int udp_open(PAL_HANDLE* hdl, const char* type, const char* uri, int acce
memcpy(buf, uri, len + 1);
if (strcmp_static(type, "udp.srv"))
if (!strcmp_static(type, "udp.srv"))
return udp_bind(hdl, buf, options);
if (strcmp_static(type, "udp"))
if (!strcmp_static(type, "udp"))
return udp_connect(hdl, buf, options);
return -PAL_ERROR_NOTSUPPORT;
+3 -3
View File
@@ -57,7 +57,7 @@ static int pipe_open (PAL_HANDLE *handle, const char * type,
const char * uri, int access, int share,
int create, int options)
{
if (strcmp_static(type, "pipe") && !*uri)
if (!strcmp_static(type, "pipe") && !*uri)
return pipe_private(handle);
char * endptr;
@@ -74,10 +74,10 @@ static int pipe_open (PAL_HANDLE *handle, const char * type,
if (*endptr)
return -PAL_ERROR_INVAL;
if (strcmp_static(type, "pipe.srv"))
if (!strcmp_static(type, "pipe.srv"))
return pipe_listen(handle, pipeid, create);
if (strcmp_static(type, "pipe"))
if (!strcmp_static(type, "pipe"))
return pipe_connect(handle, pipeid, connid, create);
return -PAL_ERROR_INVAL;
+4 -4
View File
@@ -62,10 +62,10 @@ static int tcp_open (PAL_HANDLE *handle, const char * type, const char * uri,
char uri_buf[PAL_SOCKADDR_SIZE];
memcpy(uri_buf, uri, uri_len);
if (strcmp_static(type, "tcp.srv"))
if (!strcmp_static(type, "tcp.srv"))
return tcp_listen(handle, uri_buf, create);
if (strcmp_static(type, "tcp"))
if (!strcmp_static(type, "tcp"))
return tcp_connect(handle, uri_buf, create);
return -PAL_ERROR_NOTSUPPORT;
@@ -106,10 +106,10 @@ static int udp_open (PAL_HANDLE *hdl, const char * type, const char * uri,
memcpy(buf, uri, len + 1);
if (strcmp_static(type, "udp.srv"))
if (!strcmp_static(type, "udp.srv"))
return udp_bind(hdl, buf, create);
if (strcmp_static(type, "udp"))
if (!strcmp_static(type, "udp"))
return udp_connect(hdl, buf);
return -PAL_ERROR_NOTSUPPORT;