I would a variable local to the function to be used for this and only strcpy to default_device when the final device is found.