[PATCH v2 1/2] build: Fix -Wdiscarded-qualifier warnings