Cleaning up the Gui4Cli source i replaced in a working version just one line:
if (p = (UBYTE *)AllocVec(strlen(val)+2, ANYMEM))
with
if (p = (UBYTE *)AllocVecTags(strlen(val)+2, AVT_TYPE, MEMF_ANY, TAG_DONE))
p is used in allocating a directory filter attribute.
(AllocVec is mentioned as "obsolete use AllocVecTaglist")
When i load a gui(script) with the Gui4Cli interpreter using such attribute i get an immediate and very unhelpfull crash.
I don't get it how this simple substitution can have this effect.
AllocVecTags
Re: AllocVecTags
Read the autodoc: only MEMF_PRIVATE, MEMF_SHARED or MEMF_EXECUTABLE is allowed for AVT_Type.
Re: AllocVecTags
@ZeroG,
thanks, i was convinced i did check the autodoc about this a week before.
The crash was immediate, and i had introduced a lot of other changes that i did check before writing to this forum
I am rather disappointed thet the compiler does not give any warning, error or undefined reference in this case.
Maybe this thread should go to the SDK section.
thanks, i was convinced i did check the autodoc about this a week before.
The crash was immediate, and i had introduced a lot of other changes that i did check before writing to this forum
I am rather disappointed thet the compiler does not give any warning, error or undefined reference in this case.
Maybe this thread should go to the SDK section.
Re: AllocVecTags
You are disappointed that the compiler didn't tell you you were passing wrong value to a function, aren't you?JosDuchIt wrote: I am rather disappointed thet the compiler does not give any warning, error or undefined reference in this case.
Maybe this thread should go to the SDK section.
If that's the case then it would be similar to be disappointed because the compiler didn't throw anything for
Code: Select all
printf("age=%ld\n", nWeight);
AmigaOne X1000 running AOS 4 beta
AmigaOne XE/G4
Amiga 1200/PPC 603e + BVision PPC
AmigaOne XE/G4
Amiga 1200/PPC 603e + BVision PPC
Re: AllocVecTags
That is impossible because tag IDs and tag data are all uint32 types. There are no types for the compiler to check.JosDuchIt wrote:I am rather disappointed thet the compiler does not give any warning, error or undefined reference in this case.
ExecSG Team Lead
Re: AllocVecTags
It seems to me that as the set of acceptable values is (very) limited, there should be no problem in giving an error when a not acceptable value is proposed.
Re: AllocVecTags
It seems to me you didn't realized that the compiler has no idea what AllocVecTags is actually doing (that's the job of the OS). Nonetheless what the compiler *does* know is that it takes variable number of integer arguments and that it can check (and do it), nothing more. Unless you want to build the AmigaOS API into GCC it will never be able to do what you are saying (see my sample above what you want is at the same level).JosDuchIt wrote:It seems to me that as the set of acceptable values is (very) limited, there should be no problem in giving an error when a not acceptable value is proposed.
This is the drawback of the flexibility given by TagItems: in the end it's only an array of 32bits integers...
EDIT: typo
Last edited by abalaban on Tue Oct 11, 2011 9:10 am, edited 1 time in total.
AmigaOne X1000 running AOS 4 beta
AmigaOne XE/G4
Amiga 1200/PPC 603e + BVision PPC
AmigaOne XE/G4
Amiga 1200/PPC 603e + BVision PPC
Re: AllocVecTags
It did not seem to you: you are quite right. I am not pretendig to be a compiler expert or even a C expert, Far from that. I can't but rephrase that i am rather disappointed that "the SDK does not provide more in detecting wong input to functions with a limited number of acceptable parameter values" If the easiest solution to this means that such library functions should be rewritten to fail more gracefully and provide help info, i am all for it.It seems to me you didn't realized that the compiler as no idea what AllocVecTags is actually doing (that's the job of the OS). Nonetheless what the compiler *does* know is that it takes variable number of integer arguments and that it can check (and do it), nothing more. Unless you want to build the AmigaOS API into GCC it will never be able to do what you are saying (see my sample above what you want is at the same level).
If all this is unrealistic, so be it.
Re: AllocVecTags
I agree with you that such a vital function AllocVecTags() could be more error tolerant providing at least a graceful return with adequate error code, either a fallback value for such error.JosDuchIt wrote:If the easiest solution to this means that such library functions should be rewritten to fail more gracefully and provide help info, i am all for it.
AmigaOne X1000 running AOS 4 beta
AmigaOne XE/G4
Amiga 1200/PPC 603e + BVision PPC
AmigaOne XE/G4
Amiga 1200/PPC 603e + BVision PPC
- tonyw
- AmigaOS Core Developer
- Posts: 1479
- Joined: Wed Mar 09, 2011 1:36 pm
- Location: Sydney, Australia
Re: AllocVecTags
It is vital that you check for and handle the failure return (which is NULL in this case). You will also get a NULL return if you ask it for a zero length allocation, so for instance if your string is "", you will get a failure return.
Also, you should have had a warning from gcc about using the assignment "p = xxx" as a truth value. It would have suggested putting parentheses around the expression. If you don't have warnings enabled in your makefile (and abort on error if any warnings reported), you are running a real risk of compiling code with built-in problems.
Also, you should have had a warning from gcc about using the assignment "p = xxx" as a truth value. It would have suggested putting parentheses around the expression. If you don't have warnings enabled in your makefile (and abort on error if any warnings reported), you are running a real risk of compiling code with built-in problems.
cheers
tony
tony