21755. The driver of a motor vehicle may overtake and pass another
vehicle upon the right only under conditions permitting such movement
in safety. In no event shall such movement be made by driving off
the paved or main-traveled portion of the roadway.
First of all, you need to understand that the officer will have the burden to prove that your passing on the right was unsafe. Just saying that you were passing on the right is not enough. You should cross examine him diligently. You should ask him specifically what was unsafe? Did you almost hit someone? Did the person you were passing have to take some evasive action? Did you squeal your tires or lose control of your vehicle? If not, then just what about your actions were unsafe? Note that the statute says nothing about sharing a lane, so just because there wasn't a line painted in between you isn't enough. After all, motorcycles do this (legally) all the time.