grc: fixes undefined behavior in get_nports() (WIP)