Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] find RLIM_NLIMITS correctly on Cygwin
reply 2/2 to workers/45590
> 2020/03/21 4:18, Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
>
> Jun T wrote on Tue, 25 Feb 2020 18:38 +0900:
>
>> +++ b/Src/Builtins/rlimits.c
>> @@ -53,11 +40,214 @@ enum {
>> +/* table of known resources */
>> +static resinfo_t known_resources[] = {
>> + {RLIMIT_CPU, "cputime", ZLIMTYPE_TIME, 1,
>> + 't', "cpu time (seconds)"},
>> + {RLIMIT_FSIZE, "filesize", ZLIMTYPE_MEMORY, 512,
>> + 'f', "file size (blocks)"},
>> ⋮
>
> What will happen if two different elements of this array have the same
> option letter?
(snip)
> Currently, each of the letters [mrvx] is used by two different elements.
> I haven't checked whether both elements of any of these pairs can be
> present on a single system, but in any case, more collisions may be
> added in the future.
I believe *currently* there is no conflict. I was just hoping that
if someone add a new resource (with a new option letter) in the future
they will be sure to test it (by running 'ulimit-a') and notice the
conflict if any. But I agree this is too optimistic.
> Therefore, I was wondering if we should have a test for this situation,
> or possibly a runtime check; see the attached series for example.
Thank you for the patches.
Personally I feel only adding a test (B12limit.zsh) is enough for now, but
have no objection to adding a runtime check in rlimits.c.
Do we really need resinfo_mutable?
Changes to the data in known_resouces is done via the pointer current_letter:
char *current_letter = &known_resources[i].opt;
Constness of resinfo does not interfere with this.
# and the data for unknown resource (if any) is setup using the pointer
# resinfo_T *info = (resinfo_T *)zshcalloc(sizeof(resinfo_T));
# and the assignment "resinfo[i] = info" does not conflict with the
# constness of resinfo.
Using resinfo instead of resinfo_mutable gives no warning for me
(gcc on Linux and clang on macOS).
Messages sorted by:
Reverse Date,
Date,
Thread,
Author