The variable named 'disk' inside the loop was hiding the variable named 'disk' at the outer level. The outer variable was never used, get rid of it. Move the call to archive_read_disk_set_standard_lookup(disk) inside the loop so that it Does What It Should.