If you consider an algorithm like
https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm which is guaranteed not to have "overlapping" pixels, then elect's suggestion should be correct. Assuming the line starts and ends on pixel centers, the number of pixels drawn should be (x1-x0) + (y1-y0) + 1. This disregards anti-aliasing, though :)
Any hint what you're using this for? There might be a different solution if it was more clear what problem you were solving.