There is a simplier way to do what you want to:
function add_unique_post_identifier( $post_id ) {
$unique_post_identifier = get_post_meta($post_id, 'unique_post_identifier', true);
// do nothing if post type is not 'post' or identifier is already set
if ('post' != get_post_type( ( $post_id ) ) || !empty($unique_post_identifier) )
return;
$generated_id = uniqid();
update_post_meta($post_id, 'unique_post_identifier', $generated_id);
}
// run when post is created or updated
add_action( 'save_post', 'add_unique_post_identifier' );