List all posts in a category with query_post() function

There are two issues here:

  1. The use of query_posts()
  2. Undefined $pagename variable

I assume that you want to use the page slug as the string passed for the category parameter in the query arguments array? You can get that via $post->post_name, like so:

global $post;
$page_slug = $post->post_name;

Then, to pass that as a query parameter, you would pass it as 'category_name'.

Finally, you want to output a custom query, via WP_Query(), rather than call query_posts():

// Globalize $post
global $post;
// Custom query args array
$category_query_args = array(
    'category_name' => $post->post_name
);
// Instantiate category query
$category_query = new WP_Query( $category_query_args );

Then, you can loop through your custom query like so:

// Open category query loop
if ( $category_query->have_posts() ) : while ( $category_query->have_posts() ) : $category_query->the_post();
    ?>

    <div class="post-list"  id="post-<?php the_ID(); ?>">
        <h2>
             <a href="https://wordpress.stackexchange.com/questions/76679/<?php the_permalink() ?>" title=""><?php the_title(); ?></a>
             ....
        </h2>
     </div>

    <?php
// Close category query loop
endwhile; endif;
// Reset $post data
wp_reset_postdata();