Carnival's policy recommends that luggage be unlocked when you turn it over to the porter, but it is not mandatory. If you do lock it and they see something suspicious during the scanning process you will have to go to the security room on the ship and open any suspect bags in front of security for a manual check. They will not be delivered to your cabin.
I also think they randomly pull bags for a manual inspection since we had a piece which was checked last summer on the Elation and it had a letter inside saying they had opened the luggage (we didn't lock anything). I say random because that piece of luggage had only clothes in it, certainly nothing that might look unusual on an x-ray screen. No shoes, cords, appliances, booze, etc., just shirts, slacks, and underwear. But regardless we would have had to go through the hassle of going to the 'naughty room' as they sometimes call it.
It is definitely hit or miss with the luggage scanning. I had several questionable items in mine and it went through fine. Since Carnival changed their recommendation to leaving the luggage unlocked I did. I don't want called to the naughty room to open it. Not a good way to start a cruise.
A funny but true story. On my last cruise a person in my group locked their luggage. I had told him not to. So when his luggage arrived he couldn't find the keys to the locks. He had put the locks on in haste not realizing the keys were in the respective suit cases. I had my Steward talk with his Steward about this. They called someone in Engineering to come. I go to his cabin to wait for them to make sure it gets fixed. I have three people talking now in the cabin in languages I don't understand. Finally the Engineer says in English "Hold the Lock". He then hack sawed it off. They can open locks!
If you're concerned about theft, do what I do... twist ties. That way, someone who needs to get into the bag for legitimate reasons (security) can do so, yet those whose intentions are not so good won't want to waste the time to undo them.