[splint-discuss] Passed storage not completely defined
Jason blank
bofh1234 at hotmail.com
Tue Jan 26 19:06:50 PST 2010
Hello,
I have the following block code which works but splint throws a message:
Splint 3.1.2 --- 26 Jan 2010
Spec file not found: a.lcl
a.c: (in function main)
a.c:47:11: Passed storage array not completely defined (*array is undefined):
Permute (array, ...)
Storage derivable from a parameter, return value or global is not defined.
Use /*@out@*/ to denote passed or returned storage which need not be defined.
(Use -compdef to inhibit warning)
a.c:39:3: Storage *array allocated
Finished checking --- 1 code warning
Here is the code. Please keep in mind I did not write Permute. I found it on the web. I am trying to allocate an array where I don't know how many elements I am going to need. I also don't know the size of the elements. What did I do wrong?
#include <stdio.h>
#include <stdlib.h>
static void Permute(char *Perm[], size_t sizePerm, size_t unchanged) {
size_t outer = 0;
size_t inner = 0;
size_t t = 0;
char *temp[sizePerm];
if(sizePerm > unchanged) {
for(outer = unchanged; outer < sizePerm; outer++) {
*temp = Perm[outer];
for(inner = outer; inner > unchanged; inner--) {
Perm[inner] = Perm[inner - 1];
}
Perm[unchanged] = *temp;
Permute(Perm, sizePerm, unchanged+1);
for(inner = unchanged; inner < outer; inner++) {
Perm[inner] = Perm[inner + 1];
}
Perm[outer] = *temp;
}
}
else {
for (t=0;t<sizePerm;t++) {
printf("%s", Perm[t]);
}
printf("\n");
}
}
int main(int argc, char *argv[]) {
char **array; /* array to store words */
size_t numtodo;
size_t temp;
numtodo=(size_t)(argc)-1;
array=malloc(numtodo * sizeof(*array)); /*allocate size of array*/
if (array == NULL) {
printf("can't allocate memory for array\n");
exit(EXIT_FAILURE);
}
for (temp=0; temp < numtodo; temp++) {
array[temp] = argv[temp+1]; /*assign values to array */
}
Permute(array,numtodo,0);
free(array);
return 0;
}
_________________________________________________________________
Hotmail: Free, trusted and rich email service.
http://clk.atdmt.com/GBL/go/196390708/direct/01/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.cs.virginia.edu/pipermail/splint-discuss/attachments/20100126/99c1ebba/attachment.html
More information about the splint-discuss
mailing list