coding style: #ifdef blocks and real C blocks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I couldn't find any mention of #ifdef usage nor any example of how I'm
thinking of using #ifdef, so I'm posing this here.

Right now here's what I have on my local branch:

---
#ifdef USE_CURL_MULTI
	slot = get_active_multi_slot();
#else
	slot = get_active_slot();
#endif
	slot->callback_func = process_response;
	slot->callback_data = request;
	request->slot = slot;
---

I want to implement an option that's stored in the variable
"persistent_connection", which basically makes the code behave as if
USE_CURL_MULTI isn't defined. (This would make git open/close less
connections throughout the lifespan of its execution, which would
remove/minimize the number of credential prompting if authentication
is required, among other advantages.)

Here's what I thought of:

---
#ifdef USE_CURL_MULTI
	if (!persistent_connection)
		slot = get_active_multi_slot();
	else
		slot = get_active_slot();
#else
	slot = get_active_slot();
#endif
---

I thought of shortening this further to

---
#ifdef USE_CURL_MULTI
if (!persistent_connection)
	slot = get_active_multi_slot();
else
#else
	slot = get_active_slot();
#endif
	slot->callback_func = process_response;
	slot->callback_data = request;
	request->slot = slot;
---

What would you suggest?

-- 
Cheers,
Ray Chuan
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux