Skip to content

Commit

Permalink
Fix warnings, and a failing unit test (yay regression tests!).
Browse files Browse the repository at this point in the history
  • Loading branch information
Castaglia committed Apr 15, 2016
1 parent 3f1dec8 commit 9dc055b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/str.c
Expand Up @@ -458,7 +458,8 @@ const char *pr_str_strip(pool *p, const char *str) {
/* Now, find the non-whitespace end of the given string */
for (finish = &str[strlen(str)-1]; PR_ISSPACE(*finish); finish--);

len = finish - start;
/* Include for the last byte, of course. */
len = finish - start + 1;

/* The space-stripped string is, then, everything from start to finish. */
dup_str = pstrndup(p, start, len);
Expand Down
2 changes: 1 addition & 1 deletion tests/api/privs.c
Expand Up @@ -61,7 +61,7 @@ START_TEST (privs_set_nonroot_daemon_test) {

res = set_nonroot_daemon(-1);
fail_unless(res < 0, "Failed to handle non-Boolean parameter");
fail_unless(errno = EINVAL, "Expected EINVAL (%d), got %s (%d)", EINVAL,
fail_unless(errno == EINVAL, "Expected EINVAL (%d), got %s (%d)", EINVAL,
strerror(errno), errno);

nonroot = set_nonroot_daemon(TRUE);
Expand Down
4 changes: 2 additions & 2 deletions tests/api/str.c
Expand Up @@ -504,8 +504,7 @@ START_TEST (pstrndup_test) {
END_TEST

START_TEST (strip_test) {
const char *str;
char *ok, *res;
const char *ok, *res, *str;

res = pr_str_strip(NULL, NULL);
fail_unless(res == NULL, "Failed to handle null arguments");
Expand Down Expand Up @@ -797,6 +796,7 @@ START_TEST (get_word_utf8_test) {

nread = fread(str, sizeof(char), sz-1, fh);
fail_if(ferror(fh), "Error reading '%s': %s", path, strerror(errno));
fail_unless(nread > 0, "Expected >0 bytes read, got 0");

res = pr_str_get_word(&str, 0);
fail_unless(res != NULL, "Failed to handle UTF8 argument: %s",
Expand Down

0 comments on commit 9dc055b

Please sign in to comment.