While assigning in a while ((var = get()) != NULL) { ... } loop is often cleaner than the alternatives, there is no benefit to it in an if, especially immediately following var's declaration.  <code>
int gres = getaddrinfo(ptr, servname, &query, &response);
if (gres != 0)
</code> is invariably clearer !