From my understanding of all this why the cop showed up doesn't matter, the fact that you more or less invited him in means thats the search was legal. If you had told him "no" you can't come in then he would have had to get a warrant to enter your house. I'm not sure if smelling it is probable...