Cod has two of these single-barreled 40-mm guns mounted fore and aft on her bridge deck. This is the same configuration as she had on her 7th (and last) war patrol of World War II. These guns were primarily intended as protection against aircraft but were often used against small surface targets when the 5-inch deck gun was considered excessive for the intended target or the 50-caliber machine guns too small.
The 5-inch, 25 caliber wet gun has a stainless steel liner inside the barrel to resist corrosion from sea water and can thus be submerged and flooded without harm to the gun. Though the barrel is relatively short (only 125 inches) for the diameter of the projectile (5 inches) the rolling of the submarine's deck makes a longer barrel of little value. (Longer barrels provide better aiming accuracy if the gun can be held steady while aiming and firing.)
Cod also carried a number of 50 caliber machine guns which were stowed in water-tight lockers when not in use. When needed the machine guns can be quickly attached to mounts located on the bridge and on the main deck near the bridge.
The photo below shows one of Cod's 50 caliber machine guns in use during a gun action in July, 1945 while on her 7th war patrol.