Question about "Running test"


I have one test about style that I can not pass.
There is one warning that I don’t understand.
what does that mean? and what am I supposed to do with it?

See Public splint test: memory leak

1 Like

In your case the issue seems to be of a different nature:
You open an additional superfluous block which might confuse readers and is therefore reported by splint:

void insert(Trie *dict, char *str) {
  { // not needed
  } // not needed

The warning is a bit hard to read.

Note to other students with a similar issue:
This error might also indicate a mutation of a parameter which is confusing as later on you might want to use the original value of the parameter but you overwrote it.

1 Like

Thanks! you’re right. I found I have a extra { }
now passed!

I get the same error code running this test, but for me it seems that i does’nt have an extra { } or somthing like this.

You modify the given argument by overwriting it in your function.
This is bad style as it is confusing to the person reading your code.
You might look sometime later at your code and add something that needs the argument of the function.
But your function overwrote the argument (which is not always easy to notice). Therefore, the original value is lost.

One solution would be to create a new variable for the thing you want to change and initialize it with the argument.

ok, i found a way that it works, i’m just wondering why i get this error only in the function insert, i use the same line in lookup and there it works just fine

In the other function, the access to the (possibly changed) trie is only read and not written to. Additionally, the changing instructions are in more direct correspondence with the reading accesses.
Therefore, the splint configuration judges this as less error-prone.

Nevertheless, I would change it also there to make the code more readable and debuggable.