Declare buf len in only one location