wget-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: wget2 | Draft: Small fixes (!505)


From: Avinash Sonawane (@rootkea)
Subject: Re: wget2 | Draft: Small fixes (!505)
Date: Wed, 27 Apr 2022 11:52:49 +0000



Avinash Sonawane commented on a discussion on unit-tests/test.c: 
https://gitlab.com/gnuwget/wget2/-/merge_requests/505#note_925924005

>       CHECK(!wget_memdup(NULL, 4));
>       CHECK(p = wget_memdup("xxx", 0)); xfree(p);
>       CHECK(p = wget_memdup("xxx", 4));
> -     CHECK(!memcmp(p, "xxx", 4)); xfree(p);
> +     if (p) {

Ummm.. I don't follow.

1. `wget_memdup` can return NULL if no more memory available. We detect this 
failure in `check()`: print the message and increment the `failed` count.
2. if `wget_memdup` doesn't return `NULL`, only then we perform the `memcmp` 
test.
3. **Generally**, `wget_memdup("xxx", 4)` is not supposed to be returning 
`NULL` but `wget_memdup(NULL, 0)` should **never** return a non-NULL pointer. 
We don't expect that to happen and yet there is a simple check covering that 
case. If a fault should indeed be triggered then cases like these are the prime 
candidates for that IMO.

I'd further argue that if indeed fault should be triggered then nearly all the 
tests in `test_mem()` warrant that. But then, do we really should be triggering 
the fault or the current system of simple checks: print message + increment 
`failed` is enough?

-- 
Reply to this email directly or view it on GitLab: 
https://gitlab.com/gnuwget/wget2/-/merge_requests/505#note_925924005
You're receiving this email because of your account on gitlab.com.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]