You generally use sizeof when you don't already know the size of the thing, for example when the user enters a value, or the value is determined programmatically. It is also used when dynamically allocating memory with malloc. They probably just used sizeof so code_buff would be the correct length if someone changed the default code.
But in this case, the sizeof call will return 6 every time.