Fix array, url and bump uarch version

This commit is contained in:
tezc 2020-12-27 08:34:10 +03:00
parent 159996a896
commit 35a06b702a
9 changed files with 41 additions and 15 deletions

View File

@ -12,7 +12,7 @@ jobs:
name: Build on aarch64
steps:
- uses: actions/checkout@v2.1.0
- uses: uraimo/run-on-arch-action@v2.0.7
- uses: uraimo/run-on-arch-action@v2.0.8
name: Build artifact
id: build
with:

View File

@ -12,7 +12,7 @@ jobs:
name: Build on armv6
steps:
- uses: actions/checkout@v2.1.0
- uses: uraimo/run-on-arch-action@v2.0.7
- uses: uraimo/run-on-arch-action@v2.0.8
name: Build artifact
id: build
with:

View File

@ -12,7 +12,7 @@ jobs:
name: Build on armv7
steps:
- uses: actions/checkout@v2.1.0
- uses: uraimo/run-on-arch-action@v2.0.7
- uses: uraimo/run-on-arch-action@v2.0.8
name: Build artifact
id: build
with:

View File

@ -12,7 +12,7 @@ jobs:
name: Build on ppc64le
steps:
- uses: actions/checkout@v2.1.0
- uses: uraimo/run-on-arch-action@v2.0.7
- uses: uraimo/run-on-arch-action@v2.0.8
name: Build artifact
id: build
with:

View File

@ -12,7 +12,7 @@ jobs:
name: Build on s390x
steps:
- uses: actions/checkout@v2.1.0
- uses: uraimo/run-on-arch-action@v2.0.7
- uses: uraimo/run-on-arch-action@v2.0.8
name: Build artifact
id: build
with:

View File

@ -220,4 +220,6 @@ int main(int argc, char *argv[])
test1();
fail_test();
bounds_test();
return 0;
}

View File

@ -137,7 +137,7 @@ cleanup_mutex:
cleanup_attr:
pthread_mutexattr_destroy(&attr);
error:
strncpy(cond->err, strerror(rc), sizeof(cond->err));
strncpy(cond->err, strerror(rc), sizeof(cond->err) - 1);
return -1;
}
@ -148,13 +148,13 @@ int sc_cond_term(struct sc_cond *cond)
rv = pthread_mutex_destroy(&cond->mtx);
if (rv != 0) {
rc = -1;
strncpy(cond->err, strerror(rv), sizeof(cond->err));
strncpy(cond->err, strerror(rv), sizeof(cond->err) - 1);
}
rv = pthread_cond_destroy(&cond->cond);
if (rv != 0) {
rc = -1;
strncpy(cond->err, strerror(rv), sizeof(cond->err));
strncpy(cond->err, strerror(rv), sizeof(cond->err) - 1);
}
return rc;

View File

@ -35,6 +35,7 @@ struct sc_url *sc_url_create(const char *str)
const char *s2 = "%.*s%c%.*s%c%.*s%c%.*s%c%.*s%c%.*s%c%.*s%c";
const char *authority = "//";
int diff;
unsigned long val;
size_t len, full_len, parts_len;
size_t scheme_len = 0, authority_len = 0, userinfo_len = 0;
@ -120,7 +121,7 @@ struct sc_url *sc_url_create(const char *str)
parts_len -= (query_len != 0);
parts_len -= (fragment_len != 0);
url = sc_url_malloc(sizeof(struct sc_url) + parts_len + full_len);
url = sc_url_malloc(sizeof(*url) + parts_len + full_len);
if (url == NULL) {
return NULL;
}
@ -135,12 +136,15 @@ struct sc_url *sc_url_create(const char *str)
scheme_len -= (scheme_len != 0); // Skip ":"
userinfo_len -= (userinfo_len != 0); // Skip "@"
port_len -= (port_len != 0); // Skip ":"
port += (port_len != 0); // Skip ":"
query_len -= (query_len != 0); // Skip "?"
query += (query_len != 0); // Skip "?"
fragment_len -= (fragment_len != 0); // Skip "#"
fragment += (fragment_len != 0); // Skip "#"
diff = port_len != 0;
port_len -= diff; // Skip ":"
port += diff; // Skip ":"
diff = (query_len != 0);
query_len -= diff; // Skip "?"
query += diff; // Skip "?"
diff = (fragment_len != 0);
fragment_len -= diff; // Skip "#"
fragment += diff; // Skip "#"
len = sprintf(dest, s2, scheme_len, scheme, 0, userinfo_len, userinfo, 0,
host_len, host, 0, port_len, port, 0, path_len, path, 0,

View File

@ -210,6 +210,25 @@ void test11(void)
sc_url_destroy(url);
}
void test12(void)
{
struct sc_url *url;
const char* f = "foo://user:password@example.com:1/over/there?x#3";
url = sc_url_create(f);
assert(url != NULL);
assert(strcmp(url->str, f) == 0);
assert(strcmp(url->scheme, "foo") == 0);
assert(strcmp(url->userinfo, "user:password") == 0);
assert(strcmp(url->host, "example.com") == 0);
assert(strcmp(url->port, "1") == 0);
assert(strcmp(url->path, "/over/there") == 0);
assert(strcmp(url->query, "x") == 0);
assert(strcmp(url->fragment, "3") == 0);
sc_url_destroy(url);
}
#ifdef SC_HAVE_WRAP
bool fail_malloc = false;
@ -255,6 +274,7 @@ int main(int argc, char *argv[])
test9();
test10();
test11();
test12();
fail_test();
return 0;
}